diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index ffed409..e8cee20 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -44,7 +44,8 @@ include(${PROJECT_SOURCE_DIR}/../cmake/modules/AddCMakeProject.cmake) set(supported_packages Boost heatshrink Catch2 ZLIB pybind11) include(CMakeDependentOption) -option(${PROJECT_NAME}_SELECT_ALL "Choose all external projects to be built." ON) +option(${PROJECT_NAME}_SELECT_ALL "Choose all external projects to be selected (create build target for them)." ON) +option(${PROJECT_NAME}_BUILD_ALL "Choose all external projects to be built." ON) find_package(Git REQUIRED) @@ -52,8 +53,8 @@ find_package(Git REQUIRED) set(PATCH_CMD ${GIT_EXECUTABLE} apply --verbose --ignore-space-change --whitespace=fix) foreach (pkg ${supported_packages}) - option(${PROJECT_NAME}_SELECT_${pkg} "Select package ${pkg} to be built." OFF) - if (${PROJECT_NAME}_SELECT_ALL OR ${PROJECT_NAME}_SELECT_${pkg}) + option(${PROJECT_NAME}_BUILD_${pkg} "Select package ${pkg} to be built." OFF) + if (${PROJECT_NAME}_SELECT_ALL OR ${PROJECT_NAME}_BUILD_ALL OR ${PROJECT_NAME}_BUILD_${pkg}) include(${pkg}/${pkg}.cmake) endif () endforeach() diff --git a/deps/CMakePresets.json b/deps/CMakePresets.json index bed0ef5..00941b5 100644 --- a/deps/CMakePresets.json +++ b/deps/CMakePresets.json @@ -21,7 +21,7 @@ "description": "Python module dependencies", "binaryDir": "${sourceDir}/build-python-module", "cacheVariables": { - "LibBGCode_Deps_SELECT_pybind11": true + "LibBGCode_Deps_BUILD_pybind11": true } }, { @@ -30,7 +30,7 @@ "binaryDir": "${sourceDir}/build-wasm", "cacheVariables": { "CMAKE_BUILD_TYPE": "MinSizeRel", - "LibBGCode_Deps_SELECT_ZLIB": { + "LibBGCode_Deps_BUILD_ZLIB": { "type": "BOOL", "value": "ON" } diff --git a/deps/ZLIB/ZLIB.cmake b/deps/ZLIB/ZLIB.cmake index eadde9b..5ee78aa 100644 --- a/deps/ZLIB/ZLIB.cmake +++ b/deps/ZLIB/ZLIB.cmake @@ -1,7 +1,7 @@ set(_exclude_from_all OFF) -if (UNIX AND NOT ${PROJECT_NAME}_SELECT_ZLIB AND NOT EMSCRIPTEN) +if (UNIX AND NOT ${PROJECT_NAME}_BUILD_ZLIB AND NOT EMSCRIPTEN AND NOT ${PROJECT_NAME}_BUILD_ALL) set(_exclude_from_all ON) endif () diff --git a/deps/autobuild.cmake b/deps/autobuild.cmake index 84600d6..e7d998a 100644 --- a/deps/autobuild.cmake +++ b/deps/autobuild.cmake @@ -35,8 +35,15 @@ endif () message(STATUS "build dir = ${_build_dir}") +set(_preset_arg "--preset ${${PROJECT_NAME}_DEPS_PRESET}") +if (CMAKE_VERSION VERSION_LESS 3.19) + message(WARNING "CMake presets are not supported with this version of CMake. Building all dependency packages!") + set(_preset_arg "." ) + list(APPEND _build_args "-DLibBGCode_Deps_BUILD_ALL:BOOL=ON") +endif () + execute_process( - COMMAND ${CMAKE_COMMAND} --preset ${${PROJECT_NAME}_DEPS_PRESET} "${_gen_arg}" -B ${_build_dir} ${_build_args} + COMMAND ${CMAKE_COMMAND} "${_preset_arg}" "${_gen_arg}" -B ${_build_dir} ${_build_args} WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} ${_output_quiet} ERROR_VARIABLE _deps_configure_output diff --git a/deps/pybind11/pybind11.cmake b/deps/pybind11/pybind11.cmake index 5f6ef3a..a2f6111 100644 --- a/deps/pybind11/pybind11.cmake +++ b/deps/pybind11/pybind11.cmake @@ -1,6 +1,6 @@ set(_exclude_from_all OFF) -if (NOT ${PROJECT_NAME}_SELECT_pybind11) +if (NOT ${PROJECT_NAME}_BUILD_pybind11 AND NOT ${PROJECT_NAME}_BUILD_ALL) set(_exclude_from_all ON) endif () @@ -10,4 +10,4 @@ add_cmake_project(pybind11 URL_HASH SHA256=b011a730c8845bfc265f0f81ee4e5e9e1d354df390836d2a25880e123d021f89 CMAKE_ARGS -DPYBIND11_TEST:BOOL=OFF -) \ No newline at end of file +) diff --git a/pyproject.toml b/pyproject.toml index 0631384..f1a07b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,4 +39,4 @@ install_components = ["python_modules"] build_args = ["--target", "build_and_test"] # preset = "python-module" # build_presets = ["python-module"] -# build_path = "build" \ No newline at end of file +# build_path = "build"