Skip to content

Commit d1658bb

Browse files
committed
Make CMake options depend on MASTER_PROJECT
1 parent 4436ce8 commit d1658bb

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

CMakeLists.txt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,32 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
1111
include(cmake/CPM.cmake)
1212
message("CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
1313

14-
option(BUILD_EXAMPLES "Build examples" ON)
15-
option(BUILD_TESTS "Build tests" ON)
16-
option(BUILD_FOR_DOCUMENTATION_IMAGES "Bypass wait() commands and save figures as .svg at destruction" OFF)
14+
if (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
15+
set(MASTER_PROJECT ON)
16+
else ()
17+
set(MASTER_PROJECT OFF)
18+
endif ()
19+
set(MATPLOT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
1720

18-
option(BUILD_EXPERIMENTAL_OPENGL_BACKEND "Compile target with the experimental OpenGL backend" OFF)
21+
option(BUILD_EXAMPLES "Build examples" ${MASTER_PROJECT})
22+
option(BUILD_TESTS "Build tests" ${MASTER_PROJECT})
1923

20-
option(BUILD_HIGH_RESOLUTION_WORLD_MAP "Compile the high resolution maps for geoplots" ON)
2124
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
2225

26+
option(BUILD_HIGH_RESOLUTION_WORLD_MAP "Compile the high resolution maps for geoplots" ON)
27+
option(BUILD_FOR_DOCUMENTATION_IMAGES "Bypass wait() commands and save figures as .svg at destruction" OFF)
28+
option(BUILD_EXPERIMENTAL_OPENGL_BACKEND "Compile target with the experimental OpenGL backend" OFF)
29+
2330
option(WITH_SYSTEM_CIMG "Use system-provided CImg.h instead of bundled" OFF)
2431
option(WITH_SYSTEM_NODESOUP "Use system-provided nodesoup instead of bundled" OFF)
2532

26-
if (${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
27-
set(MASTER_PROJECT ON)
28-
else()
29-
set(MASTER_PROJECT OFF)
30-
endif()
31-
set(MATPLOT_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
3233

3334
add_subdirectory(source)
3435

3536
if (MASTER_PROJECT)
3637
if (BUILD_EXAMPLES)
3738
add_subdirectory(examples)
38-
endif()
39+
endif ()
3940
if (BUILD_TESTS)
4041
add_subdirectory(test)
4142
endif()

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2069,7 +2069,7 @@ cmake --build . -j 2 --config Release
20692069
```bash
20702070
mkdir build
20712071
cmake -version
2072-
cmake .. -DCMAKE_BUILD_TYPE=Release
2072+
cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_EXAMPLES=OFF -BUILD_TESTS=OFF
20732073
cmake --build . -j 2 --config Release
20742074
cmake --install
20752075
```

0 commit comments

Comments
 (0)