DLL creation #225

Open
opened 2024-06-27 15:58:43 +02:00 by tomas1515 · 1 comment
tomas1515 commented 2024-06-27 15:58:43 +02:00 (Migrated from github.com)

I've got it installed:

  • cmake version 3.30.0-rc4
  • Visual Studio 2022
    When executing (cmake ... -G "Visual Studio 17 2022" -A x64 AND cmake --build . --config Release) creates a file with *.lib extension but I need *.dll how do I do it?
I've got it installed: - cmake version 3.30.0-rc4 - Visual Studio 2022 When executing (cmake ... -G "Visual Studio 17 2022" -A x64 AND cmake --build . --config Release) creates a file with *.lib extension but I need *.dll how do I do it?
shiena commented 2025-07-15 06:21:01 +02:00 (Migrated from github.com)
diff --git a/sdk_core/CMakeLists.txt b/sdk_core/CMakeLists.txt
--- a/sdk_core/CMakeLists.txt	(revision 9306596a2bf15c1343bc023b497465ed0a32909d)
+++ b/sdk_core/CMakeLists.txt	(revision cd01649f32854b0cf651b94054728f2a4e61a3f6)
@@ -1,7 +1,16 @@
 cmake_minimum_required(VERSION 3.0)
 
-set(SDK_LIBRARY ${PROJECT_NAME}_static)
-add_library(${SDK_LIBRARY} STATIC "")
+# Option to build static or shared library
+option(BUILD_SHARED_LIBS "Build shared library" ON)
+
+set(SDK_LIBRARY ${PROJECT_NAME})
+if(BUILD_SHARED_LIBS)
+    add_library(${SDK_LIBRARY} SHARED "")
+    message(STATUS "Building shared library")
+else()
+    add_library(${SDK_LIBRARY} STATIC "")
+    message(STATUS "Building static library")
+endif()
 
 set(LIVOX_SDK_MAJOR_VERSION "2")
 set(LIVOX_SDK_MINOR_VERSION "3")
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt	(revision 9306596a2bf15c1343bc023b497465ed0a32909d)
+++ b/CMakeLists.txt	(revision cd01649f32854b0cf651b94054728f2a4e61a3f6)
@@ -17,6 +17,7 @@
 endif(UNIX)
 
 add_subdirectory(sdk_core sdk_core)
+if(NOT BUILD_SHARED_LIBS)
 add_subdirectory(sample/hub)
 add_subdirectory(sample/lidar)
 add_subdirectory(sample/hub_lvx_file)
@@ -25,3 +26,4 @@
 add_subdirectory(sample_cc/lidar)
 add_subdirectory(sample_cc/trouble_shooting)
 add_subdirectory(sample_cc/lidar_utc_sync)
+endif()
cmake .. -G "Visual Studio 17 2022" -A x64 -DBUILD_SHARED_LIBS=ON
cmake --build . --config Release
```diff diff --git a/sdk_core/CMakeLists.txt b/sdk_core/CMakeLists.txt --- a/sdk_core/CMakeLists.txt (revision 9306596a2bf15c1343bc023b497465ed0a32909d) +++ b/sdk_core/CMakeLists.txt (revision cd01649f32854b0cf651b94054728f2a4e61a3f6) @@ -1,7 +1,16 @@ cmake_minimum_required(VERSION 3.0) -set(SDK_LIBRARY ${PROJECT_NAME}_static) -add_library(${SDK_LIBRARY} STATIC "") +# Option to build static or shared library +option(BUILD_SHARED_LIBS "Build shared library" ON) + +set(SDK_LIBRARY ${PROJECT_NAME}) +if(BUILD_SHARED_LIBS) + add_library(${SDK_LIBRARY} SHARED "") + message(STATUS "Building shared library") +else() + add_library(${SDK_LIBRARY} STATIC "") + message(STATUS "Building static library") +endif() set(LIVOX_SDK_MAJOR_VERSION "2") set(LIVOX_SDK_MINOR_VERSION "3") diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt (revision 9306596a2bf15c1343bc023b497465ed0a32909d) +++ b/CMakeLists.txt (revision cd01649f32854b0cf651b94054728f2a4e61a3f6) @@ -17,6 +17,7 @@ endif(UNIX) add_subdirectory(sdk_core sdk_core) +if(NOT BUILD_SHARED_LIBS) add_subdirectory(sample/hub) add_subdirectory(sample/lidar) add_subdirectory(sample/hub_lvx_file) @@ -25,3 +26,4 @@ add_subdirectory(sample_cc/lidar) add_subdirectory(sample_cc/trouble_shooting) add_subdirectory(sample_cc/lidar_utc_sync) +endif() ``` ``` cmake .. -G "Visual Studio 17 2022" -A x64 -DBUILD_SHARED_LIBS=ON cmake --build . --config Release ```
This repo is archived. You cannot comment on issues.
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mmr/Livox-SDK#225