11# This file is just an orchestration
2- cmake_minimum_required (VERSION 3.18 )
2+ cmake_minimum_required (VERSION 3.24..3.31 )
33list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR} /cmake" )
44
5- option (CMAKE_EXPORT_COMPILE_COMMANDS "Export compile command" TRUE )
5+ # Enable output of compile commands during generation.
6+ option (CMAKE_EXPORT_COMPILE_COMMANDS "Export compile command" ON )
67
7- project (PythonNative VERSION 1.0 LANGUAGES CXX)
8+ project (PythonNative VERSION 1.0.0 LANGUAGES C CXX)
89set (PROJECT_NAMESPACE pn)
910message (STATUS "${PROJECT_NAME} version: ${PROJECT_VERSION} " )
1011#message(STATUS "major: ${PROJECT_VERSION_MAJOR}")
1112#message(STATUS "minor: ${PROJECT_VERSION_MINOR}")
1213#message(STATUS "patch: ${PROJECT_VERSION_PATCH}")
1314
15+ message (STATUS "system name: ${CMAKE_SYSTEM_NAME} " )
16+ # Set max os target version.
17+ set (CMAKE_OSX_DEPLOYMENT_TARGET 10.15)
18+
19+ set (CMAKE_CXX_STANDARD 20)
20+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
21+ set (CMAKE_CXX_EXTENSIONS OFF )
22+
23+ # Default Build Type to be Release
1424get_property (isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
1525if (isMultiConfig)
1626 if (NOT CMAKE_CONFIGURATION_TYPES )
@@ -31,7 +41,7 @@ endif()
3141# Layout build dir like install dir
3242include (GNUInstallDirs)
3343if (UNIX )
34- option (BUILD_SHARED_LIBS "Build shared libraries (.so or .dyld )." ON )
44+ option (BUILD_SHARED_LIBS "Build shared libraries (.so or .dylib )." ON )
3545 set (CMAKE_BUILD_WITH_INSTALL_RPATH TRUE )
3646 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_LIBDIR} )
3747 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} /${CMAKE_INSTALL_LIBDIR} )
@@ -58,32 +68,37 @@ else()
5868 endforeach ()
5969endif ()
6070
71+ if (MSVC AND BUILD_SHARED_LIBS )
72+ set (CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON )
73+ endif ()
74+
6175# Enable CCache if any
6276include (ccache)
6377
78+ # Build deps
79+
6480# Disable CTest targets
6581set_property (GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)
6682include (CTest)
6783
68- include (cpp)
69-
7084if (WIN32 )
7185 message (STATUS "Getting SWIG: ..." )
7286 include (swig)
7387 message (STATUS "Getting SWIG: ...DONE" )
7488endif ()
7589
7690option (FETCH_PYTHON_DEPS "Install python required modules if not available" ON )
77- message (STATUS "Python fetch dependencies: ${FETCH_PYTHON_DEPS} " )
91+ message (STATUS "Python: Fetch dependencies: ${FETCH_PYTHON_DEPS} " )
7892
7993option (VENV_USE_SYSTEM_SITE_PACKAGES "Python venv can use system site packages" OFF )
8094message (STATUS "Python: Allow venv to use system site packages: ${VENV_USE_SYSTEM_SITE_PACKAGES} " )
8195
96+ option (BUILD_EXAMPLES "Build examples" ON )
97+ message (STATUS "Build examples: ${BUILD_EXAMPLES} " )
98+
99+ include (cpp)
100+
82101include (python)
83102
84103add_subdirectory (tests)
85-
86- option (BUILD_EXAMPLES "Build examples" ON )
87- message (STATUS "Build examples: ${BUILD_EXAMPLES} " )
88104add_subdirectory (examples)
89-
0 commit comments