-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
96 lines (86 loc) · 3.11 KB
/
CMakeLists.txt
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#
# CMakeLists.txt
# Copyright 2021 ItJustWorksTM
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cmake_minimum_required (VERSION 3.16)
cmake_policy (SET CMP0022 NEW)
set (CMAKE_POLICY_DEFAULT_CMP0069 NEW) # mosquitto's CMakeLists does not behave otherwise
set (PYSMCE_BOOST_LINKING "STATIC" CACHE STRING "")
project (pySMCE
VERSION 1.4.0.5
HOMEPAGE_URL "https://github.com/ItJustWorksTM/pySMCE"
LANGUAGES CXX
)
list (APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake/Modules")
set (BUILD_SHARED_LIBS Off)
set (CMAKE_POSITION_INDEPENDENT_CODE On)
set (CMAKE_CXX_STANDARD 20) # Bump that down to 17 once libSMCE finally honors that
set (CMAKE_CXX_STANDARD_REQUIRED True)
set (CMAKE_CXX_EXTENSIONS Off)
include (CheckIPOSupported)
check_ipo_supported (RESULT ipo_result OUTPUT ipo_output)
if (ipo_result)
set (CMAKE_INTERPROCEDURAL_OPTIMIZATION On)
else ()
message (WARNING "IPO is not supported: ${ipo_output}")
endif ()
include (SetupSMCE)
set (CMAKE_CXX_STANDARD 20)
if (NOT TARGET Boost::python)
if (PYSMCE_BOOST_LINKING STREQUAL "STATIC")
set (Boost_USE_STATIC_LIBS On)
endif ()
find_package (Boost 1.74 COMPONENTS python REQUIRED)
endif ()
find_package (Python REQUIRED COMPONENTS Development)
add_library (python-dev INTERFACE)
target_include_directories (python-dev INTERFACE "${Python_INCLUDE_DIRS}")
add_library (pySMCE MODULE)
target_link_libraries (pySMCE PRIVATE SMCE_static python-dev Boost::python)
set_target_properties (pySMCE PROPERTIES
PREFIX ""
OUTPUT_NAME "smce"
)
if (WIN32 AND NOT CYGWIN)
set_target_properties (pySMCE PROPERTIES SUFFIX ".pyd")
endif ()
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_precompile_headers (pySMCE PRIVATE "<boost/python.hpp>")
endif ()
target_sources (pySMCE PRIVATE
src/pySMCE.cpp
src/pyUtils.hpp
src/Board.cpp
src/BoardConf.cpp
src/BoardView.cpp
src/PluginManifest.cpp
src/Sketch.cpp
src/SketchConf.cpp
src/Toolchain.cpp
)
if (NOT MSVC)
target_compile_options (pySMCE PRIVATE "-Wall" "-Wextra" "-Wpedantic" "-Werror" "-Wcast-align" "-Wno-missing-field-initializers")
else ()
target_compile_options (pySMCE PRIVATE "/W4" "/permissive-" "/wd4244" "/wd4251" "/wd4459" "/WX")
endif ()
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set_target_properties (pySMCE PROPERTIES LINK_FLAGS_RELEASE -s)
if (NOT APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_options (pySMCE PRIVATE -static-libstdc++ -static-libgcc)
endif ()
endif ()
install (TARGETS pySMCE DESTINATION pySMCE)
install (FILES src/__init__.py DESTINATION pySMCE)
install (FILES "${libsmce_BINARY_DIR}/SMCE_Resources.zip" DESTINATION pySMCE)