From 94bd40cd32035e2791c1b043da1e11dd0a419533 Mon Sep 17 00:00:00 2001 From: Patrick Kappl Date: Thu, 11 Jan 2024 16:02:42 +0100 Subject: [PATCH] Add separate option for building the samples --- CMakeLists.txt | 11 ++--------- cmake/variables-and-options.cmake | 8 ++++++++ 2 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 cmake/variables-and-options.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b15a0e..0017d47 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,12 +4,7 @@ project(livox_sdk) message(STATUS "main project dir: " ${PROJECT_SOURCE_DIR}) -# This variable is set by project() in CMake 3.21+ -string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}" PROJECT_IS_TOP_LEVEL) - -if(PROJECT_IS_TOP_LEVEL) - option(shared_DEVELOPER_MODE "Enable developer mode" OFF) -endif() +include(cmake/variables-and-options.cmake) set(CMAKE_CXX_STANDARD 11) @@ -27,10 +22,8 @@ if(WIN32) add_compile_definitions("WIN32") endif(WIN32) -# Always build the core SDK library add_subdirectory(sdk_core sdk_core) -# Only build the samples if this is the top-level project -if(PROJECT_IS_TOP_LEVEL) +if(BUILD_SAMPLES) add_subdirectory(sample/hub) add_subdirectory(sample/lidar) add_subdirectory(sample/hub_lvx_file) diff --git a/cmake/variables-and-options.cmake b/cmake/variables-and-options.cmake new file mode 100644 index 0000000..8a284c6 --- /dev/null +++ b/cmake/variables-and-options.cmake @@ -0,0 +1,8 @@ +# This variable is set by project() in CMake 3.21+ +string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}" PROJECT_IS_TOP_LEVEL) + +if(PROJECT_IS_TOP_LEVEL) + option(shared_DEVELOPER_MODE "Enable developer mode" OFF) +endif() + +option(BUILD_SAMPLES "Build the samples" OFF)