Skip to content

Commit 5b348ba

Browse files
authored
CMake options have project prefix
fix #315
1 parent 58d3994 commit 5b348ba

File tree

6 files changed

+721
-713
lines changed

6 files changed

+721
-713
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Matplotplusplus
22

3-
on:
3+
on:
44
push:
55
paths:
66
- '**.c'
@@ -81,7 +81,7 @@ jobs:
8181
- name: Configure
8282
working-directory: ./build
8383
run: |
84-
cmake .. ${{ matrix.config.cmake_extra_args }} -DCMAKE_BUILD_TYPE=${{ matrix.config.config }} -DBUILD_WITH_PEDANTIC_WARNINGS=ON
84+
cmake .. ${{ matrix.config.cmake_extra_args }} -DCMAKE_BUILD_TYPE=${{ matrix.config.config }} -DMATPLOTPP_BUILD_WITH_PEDANTIC_WARNINGS=ON
8585
- name: Build
8686
working-directory: ./build
8787
run: cmake --build . --parallel ${{ matrix.config.cores }} --config ${{ matrix.config.config }}

CMakeLists.txt

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,29 @@ set_optimization_flags() # detect and set default optimization flags
3333
set_compiler_booleans() # detect compiler
3434

3535
# What to build
36-
option(BUILD_EXAMPLES "Build examples" ${MASTER_PROJECT})
37-
option(BUILD_TESTS "Build tests" ${MASTER_PROJECT})
38-
option(BUILD_INSTALLER "Build installer target" ${MASTER_PROJECT})
39-
option(BUILD_PACKAGE "Build package" ${MASTER_PROJECT})
36+
option(MATPLOTPP_BUILD_EXAMPLES "Build examples" ${MASTER_PROJECT})
37+
option(MATPLOTPP_BUILD_TESTS "Build tests" ${MASTER_PROJECT})
38+
option(MATPLOTPP_BUILD_INSTALLER "Build installer target" ${MASTER_PROJECT})
39+
option(MATPLOTPP_BUILD_PACKAGE "Build package" ${MASTER_PROJECT})
4040

4141
# How to build
42-
option(BUILD_WITH_PEDANTIC_WARNINGS "Use pedantic warnings. This is useful for developers because many of these warnings will be in continuous integration anyway." ${DEBUG_MODE})
43-
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
44-
option(BUILD_WITH_SANITIZERS "Use pedantic warnings." ${DEBUG_MODE})
42+
option(MATPLOTPP_BUILD_WITH_PEDANTIC_WARNINGS "Use pedantic warnings. This is useful for developers because many of these warnings will be in continuous integration anyway." ${DEBUG_MODE})
43+
option(MATPLOTPP_BUILD_SHARED_LIBS "Build shared libraries" ${BUILD_SHARED_LIBS})
44+
option(MATPLOTPP_BUILD_WITH_SANITIZERS "Use pedantic warnings." ${DEBUG_MODE})
4545

4646
# MSVC hacks
47-
option(BUILD_WITH_MSVC_HACKS "Accept utf-8 in MSVC by default." ON)
48-
option(BUILD_WITH_UTF8 "Accept utf-8 in MSVC by default." ON)
49-
option(BUILD_WITH_EXCEPTIONS "Add compiler flags to use exceptions." ON)
47+
option(MATPLOTPP_BUILD_WITH_MSVC_HACKS "Accept utf-8 in MSVC by default." ON)
48+
option(MATPLOTPP_BUILD_WITH_UTF8 "Accept utf-8 in MSVC by default." ON)
49+
option(MATPLOTPP_BUILD_WITH_EXCEPTIONS "Add compiler flags to use exceptions." ON)
5050

5151
# Features
52-
option(BUILD_HIGH_RESOLUTION_WORLD_MAP "Compile the high resolution maps for geoplots" ON)
53-
option(BUILD_FOR_DOCUMENTATION_IMAGES "Bypass show() commands and save figures as .svg at destruction" OFF)
54-
option(BUILD_EXPERIMENTAL_OPENGL_BACKEND "Compile target with the experimental OpenGL backend" OFF)
52+
option(MATPLOTPP_BUILD_HIGH_RESOLUTION_WORLD_MAP "Compile the high resolution maps for geoplots" ON)
53+
option(MATPLOTPP_BUILD_FOR_DOCUMENTATION_IMAGES "Bypass show() commands and save figures as .svg at destruction" OFF)
54+
option(MATPLOTPP_BUILD_EXPERIMENTAL_OPENGL_BACKEND "Compile target with the experimental OpenGL backend" OFF)
5555

5656
# Where to find dependencies
57-
option(WITH_SYSTEM_CIMG "Use system-provided CImg.h instead of bundled" OFF)
58-
option(WITH_SYSTEM_NODESOUP "Use system-provided nodesoup instead of bundled" OFF)
57+
option(MATPLOTPP_WITH_SYSTEM_CIMG "Use system-provided CImg.h instead of bundled" OFF)
58+
option(MATPLOTPP_WITH_SYSTEM_NODESOUP "Use system-provided nodesoup instead of bundled" OFF)
5959

6060
#######################################################
6161
### Apply global options ###
@@ -64,23 +64,23 @@ option(WITH_SYSTEM_NODESOUP "Use system-provided nodesoup instead of bundled" OF
6464
if (MASTER_PROJECT)
6565
message("Setting global options")
6666
# Maybe add sanitizers to all targets
67-
if (BUILD_WITH_SANITIZERS AND NOT EMSCRIPTEN)
67+
if (MATPLOTPP_BUILD_WITH_SANITIZERS AND NOT EMSCRIPTEN)
6868
add_sanitizers()
6969
endif ()
7070

7171
# Allow exceptions in MSVC
72-
if (MSVC AND BUILD_WITH_EXCEPTIONS)
72+
if (MSVC AND MATPLOTPP_BUILD_WITH_EXCEPTIONS)
7373
add_compile_options(/EHsc)
7474
endif ()
7575

7676
# Allow utf-8 in MSVC
77-
if (BUILD_WITH_UTF8 AND MSVC)
77+
if (MATPLOTPP_BUILD_WITH_UTF8 AND MSVC)
7878
set(CMAKE_CXX_FLAGS "/utf-8")
7979
endif ()
8080

8181
# MSVC hack to disable windows min/max
8282
# http://www.suodenjoki.dk/us/archive/2010/min-max.htm
83-
if (MSVC AND BUILD_WITH_MSVC_HACKS)
83+
if (MSVC AND MATPLOTPP_BUILD_WITH_MSVC_HACKS)
8484
# Check for min in Windows.h
8585
# include(CheckSymbolExists)
8686
# check_symbol_exists(min "WinDef.h" HAVE_WINDOWS_MINMAX)
@@ -101,7 +101,7 @@ add_subdirectory(source)
101101
#######################################################
102102
### Tests ###
103103
#######################################################
104-
if (BUILD_TESTS)
104+
if (MATPLOTPP_BUILD_TESTS)
105105
include(CTest)
106106
enable_testing()
107107
add_subdirectory(test)
@@ -110,14 +110,14 @@ endif ()
110110
#######################################################
111111
### Examples ###
112112
#######################################################
113-
if (BUILD_EXAMPLES)
113+
if (MATPLOTPP_BUILD_EXAMPLES)
114114
add_subdirectory(examples)
115115
endif ()
116116

117117
#######################################################
118118
### Installer ###
119119
#######################################################
120-
if (BUILD_INSTALLER)
120+
if (MATPLOTPP_BUILD_INSTALLER)
121121
# https://cliutils.gitlab.io/modern-cmake/chapters/install/installing.html
122122
# Set variable where the cmake config is
123123
set(CONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/Matplot++)
@@ -147,7 +147,7 @@ if (BUILD_INSTALLER)
147147
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Matplot++)
148148

149149
# Install cmake to find filesystem as a dependency
150-
if (NOT BUILD_SHARED_LIBS)
150+
if (NOT MATPLOTPP_BUILD_SHARED_LIBS)
151151
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindFilesystem.cmake
152152
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Matplot++)
153153
endif ()
@@ -156,7 +156,7 @@ endif ()
156156
#######################################################
157157
### Packages ###
158158
#######################################################
159-
if (BUILD_INSTALLER AND BUILD_PACKAGE)
159+
if (MATPLOTPP_BUILD_INSTALLER AND MATPLOTPP_BUILD_PACKAGE)
160160
# Set the cpack variables
161161
# https://cliutils.gitlab.io/modern-cmake/chapters/install/packaging.html
162162

CMakePresets.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@
1919
{
2020
"name": "system",
2121
"displayName": "Build for system installation",
22-
"description": "Bulid for system installation (BUILD_EXAMPLES and BUILD_TESTS are OFF)",
22+
"description": "Build for system installation (MATPLOTPP_BUILD_EXAMPLES and MATPLOTPP_BUILD_TESTS are OFF)",
2323
"binaryDir": "${sourceDir}/build/system",
2424
"generator": "Unix Makefiles",
2525
"cacheVariables": {
26-
"BUILD_EXAMPLES": "OFF",
27-
"BUILD_TESTS": "OFF",
28-
"BUILD_SHARED_LIBS": "ON",
26+
"MATPLOTPP_BUILD_EXAMPLES": "OFF",
27+
"MATPLOTPP_BUILD_TESTS": "OFF",
28+
"MATPLOTPP_BUILD_SHARED_LIBS": "ON",
2929
"CMAKE_BUILD_TYPE": "Release",
3030
"CMAKE_INTERPROCEDURAL_OPTIMIZATION": "ON"
3131
}
3232
},
3333
{
3434
"name": "local",
35-
"displayName":"Build for installation in $HOME/.local",
35+
"displayName": "Build for installation in $HOME/.local",
3636
"description": "Build for installaton in $HOME/.local",
3737
"inherits": "system",
3838
"binaryDir": "${sourceDir}/build/local",

Matplot++Config.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@PACKAGE_INIT@
22

33
# How this Matplot++ installation was built
4-
set(MATPLOT_BUILT_SHARED "@BUILD_SHARED_LIBS@")
4+
set(MATPLOT_BUILT_SHARED "@MATPLOTPP_BUILD_SHARED_LIBS@")
55
set(MATPLOT_BUILT_CXX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@")
66
set(MATPLOT_BUILT_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@")
77

0 commit comments

Comments
 (0)