-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
62 lines (51 loc) · 1.95 KB
/
CMakeLists.txt
File metadata and controls
62 lines (51 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
cmake_minimum_required(VERSION 3.18)
project(pythonfmu-export)
# ==============================================================================
# Build settings
# ==============================================================================
set(BUILD_SHARED_LIBS ON)
# ==============================================================================
# Global internal configuration
# ==============================================================================
if (MSVC)
# https://stackoverflow.com/questions/14172856/compile-with-mt-instead-of-md-using-cmake
set(CompilerFlags
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
)
foreach (CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach ()
endif ()
# Automatically export all symbols in Windows DLLs.
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# ==============================================================================
# Dependencies
# ==============================================================================
# Force to use stable Python ABI https://docs.python.org/3/c-api/stable.html
option (USE_PYTHON_SABI "Use Python stable ABI" ON)
if (USE_PYTHON_SABI AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.26)
add_compile_definitions(Py_LIMITED_API)
find_package(Python3 REQUIRED COMPONENTS Development.SABIModule)
add_library (Python3::Module ALIAS Python3::SABIModule)
else ()
find_package(Python3 REQUIRED COMPONENTS Development.Module)
endif ()
if (WIN32)
set(TARGET_PLATFORM win)
elseif (APPLE)
set(TARGET_PLATFORM darwin)
else ()
set(TARGET_PLATFORM linux)
endif ()
if ("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
set(TARGET_PLATFORM ${TARGET_PLATFORM}64)
else ()
set(TARGET_PLATFORM ${TARGET_PLATFORM}32)
endif ()
message("Building pythonfmu-export for platform ${TARGET_PLATFORM}")
add_subdirectory(src)