Skip to content

Commit 64693d0

Browse files
committed
cmake: cleanup
1 parent f02af98 commit 64693d0

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

CMakeLists.txt

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
# This file is just an orchestration
2-
cmake_minimum_required(VERSION 3.18)
2+
cmake_minimum_required(VERSION 3.24..3.31)
33
list(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)
89
set(PROJECT_NAMESPACE pn)
910
message(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
1424
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
1525
if(isMultiConfig)
1626
if(NOT CMAKE_CONFIGURATION_TYPES)
@@ -31,7 +41,7 @@ endif()
3141
# Layout build dir like install dir
3242
include(GNUInstallDirs)
3343
if(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()
5969
endif()
6070

71+
if(MSVC AND BUILD_SHARED_LIBS)
72+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
73+
endif()
74+
6175
# Enable CCache if any
6276
include(ccache)
6377

78+
# Build deps
79+
6480
# Disable CTest targets
6581
set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)
6682
include(CTest)
6783

68-
include(cpp)
69-
7084
if(WIN32)
7185
message(STATUS "Getting SWIG: ...")
7286
include(swig)
7387
message(STATUS "Getting SWIG: ...DONE")
7488
endif()
7589

7690
option(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

7993
option(VENV_USE_SYSTEM_SITE_PACKAGES "Python venv can use system site packages" OFF)
8094
message(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+
82101
include(python)
83102

84103
add_subdirectory(tests)
85-
86-
option(BUILD_EXAMPLES "Build examples" ON)
87-
message(STATUS "Build examples: ${BUILD_EXAMPLES}")
88104
add_subdirectory(examples)
89-

cmake/python.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,8 @@ if(BUILD_TESTING)
268268
COMMAND ${VENV_Python3_EXECUTABLE} -m pip install
269269
--find-links=${CMAKE_CURRENT_BINARY_DIR}/python/dist ${PYTHON_PROJECT}==${PROJECT_VERSION}
270270
# install modules only required to run examples
271-
COMMAND ${VENV_Python3_EXECUTABLE} -m pip install pytest
271+
COMMAND ${VENV_Python3_EXECUTABLE} -m pip install
272+
pytest
272273
BYPRODUCTS ${VENV_DIR}
273274
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
274275
COMMENT "Create venv and install ${PYTHON_PROJECT}"

0 commit comments

Comments
 (0)