2021-01-28 22:40:01 +00:00
|
|
|
cmake_minimum_required(VERSION 3.17)
|
|
|
|
project(python_rgbcx)
|
|
|
|
|
2021-01-29 02:14:37 +00:00
|
|
|
# Link to Pybind
|
2021-01-29 06:01:20 +00:00
|
|
|
add_subdirectory(extern/pybind11)
|
2021-01-29 02:14:37 +00:00
|
|
|
|
2021-02-02 07:31:27 +00:00
|
|
|
# Collect source files
|
|
|
|
file(GLOB SOURCE_FILES "src/*.cpp")
|
|
|
|
file(GLOB HEADER_FILES "src/*.h")
|
|
|
|
file(GLOB PYTHON_FILES "python/*.cpp" "python/*.h")
|
2021-02-02 08:20:17 +00:00
|
|
|
file(GLOB TEST_FILES "src/test/*.c" "src/test/*.cpp" "src/test/*.h")
|
|
|
|
|
2021-02-02 07:31:27 +00:00
|
|
|
|
|
|
|
# Organize source files together for some IDEs
|
|
|
|
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCE_FILES} ${HEADER_FILES} ${PYTHON_FILES})
|
|
|
|
|
|
|
|
# Add python module
|
|
|
|
pybind11_add_module(python_rgbcx
|
|
|
|
${SOURCE_FILES}
|
|
|
|
${HEADER_FILES}
|
2021-02-06 03:44:19 +00:00
|
|
|
${PYTHON_FILES})
|
2021-01-29 00:24:30 +00:00
|
|
|
|
2021-02-02 08:20:17 +00:00
|
|
|
add_executable(test_rgbcx
|
|
|
|
${SOURCE_FILES}
|
|
|
|
${HEADER_FILES}
|
|
|
|
${TEST_FILES})
|
|
|
|
|
2021-01-29 00:24:30 +00:00
|
|
|
# Set module features, like C/C++ standards
|
2021-02-06 03:44:19 +00:00
|
|
|
target_compile_features(python_rgbcx PUBLIC cxx_std_20 c_std_11)
|
|
|
|
target_compile_features(test_rgbcx PUBLIC cxx_std_20 c_std_11)
|
|
|
|
|
|
|
|
set_property(TARGET python_rgbcx test_rgbcx PROPERTY INTERPROCEDURAL_OPTIMIZATION True) #enable FLTO if available
|
2021-02-06 07:35:06 +00:00
|
|
|
|
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
|
|
|
set_property(TARGET python_rgbcx test_rgbcx PROPERTY OSX_ARCHITECTURES_RELEASE x86_64 arm64) #Mach-O fat binary for arm and x86
|
|
|
|
endif ()
|