1
1
cmake_minimum_required (VERSION 3.8 FATAL_ERROR )
2
+
3
+ # Set compiler to g++-11)
4
+ message (STATUS "NOTE: ensure you're using a compiler version that matches the precompiled Python libraries! For this build g++-11 is recommended." )
5
+
6
+ set (CMAKE_CXX_COMPILER "g++-11" )
7
+ set (CMAKE_C_COMPILE "gcc-11" )
8
+
2
9
project (matplotlib_cpp LANGUAGES CXX )
3
10
4
11
include (GNUInstallDirs )
5
12
set (PACKAGE_NAME matplotlib_cpp )
6
13
set (INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR} /${PACKAGE_NAME}/cmake )
7
14
15
+ # Set C++ standard to C++11
16
+ set (CMAKE_CXX_STANDARD 11 )
17
+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
18
+
19
+ # Handle virtualenv or conda envs
20
+ if (DEFINED ENV{CONDA_PREFIX} )
21
+ # Let CMake know to look under the conda env directory
22
+ set (Python3_ROOT_DIR "$ENV{CONDA_PREFIX} " )
23
+ elseif (DEFINED ENV{VIRTUAL_ENV} )
24
+ set (Python3_ROOT_DIR "$ENV{VIRTUAL_ENV} " )
25
+ else ()
26
+ message (WARNING "Neither CONDA_PREFIX nor VIRTUAL_ENV is defined. Python3_ROOT_DIR will use system environment! Make sure this is intentional." )
27
+ endif ()
8
28
9
29
# Library target
10
30
add_library (matplotlib_cpp INTERFACE )
@@ -18,12 +38,16 @@ target_compile_features(matplotlib_cpp INTERFACE
18
38
)
19
39
# TODO: Use `Development.Embed` component when requiring cmake >= 3.18
20
40
find_package (Python3 COMPONENTS Interpreter Development REQUIRED )
41
+ # Print location of python3
42
+ message (STATUS "Python3 found at: ${Python3_EXECUTABLE} " )
43
+
21
44
target_link_libraries (matplotlib_cpp INTERFACE
22
45
Python3::Python
23
46
Python3::Module
24
47
)
25
48
find_package (Python3 COMPONENTS NumPy )
26
49
if (Python3_NumPy_FOUND )
50
+ message (STATUS "Found NumPy: ${Python3_NumPy_INCLUDE_DIRS} " )
27
51
target_link_libraries (matplotlib_cpp INTERFACE
28
52
Python3::NumPy
29
53
)
@@ -35,6 +59,10 @@ install(
35
59
EXPORT install_targets
36
60
)
37
61
62
+ # Print C++ build options
63
+ message (STATUS "C++ compiler: ${CMAKE_CXX_COMPILER_ID} " )
64
+ message (STATUS "C++ compiler version: ${CMAKE_CXX_COMPILER_VERSION} " )
65
+ message (STATUS "C++ compiler flags: ${CMAKE_CXX_FLAGS} " )
38
66
39
67
# Examples
40
68
add_executable (minimal examples/minimal.cpp )
0 commit comments