From 860f5d4cfceced9de423a2abbd0b7eb66b538f6a Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 24 Aug 2025 12:56:15 +0200 Subject: [PATCH] Automatically build as library if project is not toplevel --- CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dce0655a..342aa659 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,6 @@ option(MOMO_ENABLE_CLANG_TIDY "Enable clang-tidy checks" OFF) option(MOMO_ENABLE_RUST_CODE "Enable code parts written in rust" ON) option(MOMO_EMSCRIPTEN_MEMORY64 "Enable memory 64 support for emscripten builds" OFF) option(MOMO_EMSCRIPTEN_SUPPORT_NODEJS "Enable Node.js filesystem for emscripten compilation" OFF) -option(MOMO_BUILD_AS_LIBRARY "Configure and Build the sogen as a shared library (without the samples and tests)" OFF) set(MOMO_REFLECTION_LEVEL "0" CACHE STRING "Reflection level for the build") message(STATUS "Reflection level is set to: ${MOMO_REFLECTION_LEVEL}") @@ -37,6 +36,18 @@ enable_testing() ########################################## +if(PROJECT_IS_TOP_LEVEL) + set(MOMO_IS_SUBPROJECT OFF) +else() + set(MOMO_IS_SUBPROJECT ON) +endif() + +########################################## + +option(MOMO_BUILD_AS_LIBRARY "Configure and Build the sogen as a shared library (without the samples and tests)" ${MOMO_IS_SUBPROJECT}) + +########################################## + set_property(GLOBAL PROPERTY USE_FOLDERS ON) ##########################################