-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
139 lines (115 loc) · 5.15 KB
/
CMakeLists.txt
File metadata and controls
139 lines (115 loc) · 5.15 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#####################################################################################################################
#
# CMake and System Settings
#
#####################################################################################################################
cmake_minimum_required(VERSION 3.24)
option(SAM_SKIP_TOOLS "Skips the wex sandbox and Dview builds" OFF)
#
# If project isn't system_advisor_model and SAM_SKIP_TOOLS=1,
# environment vars LK_LIB and LKD_LIB can be used to specify where to find those libraries
#
if (APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET "12" CACHE STRING "Minimum OS X deployment version")
endif ()
if (UNIX AND NOT CMAKE_C_COMPILER)
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)
endif ()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if (NOT APPLE)
set(CURL_DIR build_resources/libcurl_ssl_x64)
endif ()
Project(wex C CXX)
#####################################################################################################################
#
# Compile Options per Platform
#
#####################################################################################################################
set(CMAKE_CXX_STANDARD 20)
if (MSVC)
add_compile_options(/W3 /MP)
add_compile_definitions(LK_USE_WXWIDGETS _UNICODE _MBCS _CRT_SECURE_NO_DEPRECATE=1 _CRT_NON_CONFORMING_SWPRINTFS=1 _SCL_SECURE_NO_WARNINGS=1 __WXMSW__ NOPCH FT2_BUILD_LIBRARY OPJ_STATIC FT_CONFIG_MODULES_H=\"slimftmodules.h\" FT_CONFIG_OPTIONS_H=\"slimftoptions.h\")
foreach (flag_var CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG)
set(${flag_var} "${${flag_var}} /D_DEBUG" CACHE STRING "compile flags" FORCE)
endforeach ()
else ()
add_compile_options(-Wall -Wno-unknown-pragmas -Wno-strict-aliasing)
add_compile_options(-fno-common ${wxWidgets_CXX_FLAGS})
add_definitions(-DLK_USE_WXWIDGETS -D_CRT_SECURE_NO_WARNINGS -D_MBCS -DFT2_BUILD_LIBRARY -DOPJ_STATIC -DFT_CONFIG_MODULES_H=\"slimftmodules.h\" -DFT_CONFIG_OPTIONS_H=\"slimftoptions.h\")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(_DEBUG)
else ()
add_compile_options(-O3)
endif ()
endif ()
#####################################################################################################################
#
# Packages
#
#####################################################################################################################
# setup wxWidgets
if (UNIX)
if (EXISTS /usr/local/bin/wx-config-3)
set(wxWidgets_CONFIG_EXECUTABLE /usr/local/bin/wx-config-3)
find_package(wxWidgets QUIET REQUIRED xrc stc richtext ribbon propgrid aui gl html qa adv core xml net base)
else ()
set(wxWidgets_CONFIG_EXECUTABLE $ENV{WXMSW3}/bin/wx-config)
find_package(wxWidgets QUIET REQUIRED xrc stc richtext ribbon propgrid aui gl html qa adv core xml net base)
endif ()
else ()
# set(wxWidgets_ROOT_DIR $ENV{WXMSW3})
# set(CMAKE_MAP_IMPORTED_CONFIG_DEBUG Release)
# find_package(wxWidgets QUIET REQUIRED xrc stc richtext ribbon propgrid aui gl html qa adv core xml net base scintilla)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Debug and Release Builds Configured" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++20")
# for linking to Release build of ortools
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
# Get the current debug flags and remove the /D_DEBUG option.
string(REPLACE "/D_DEBUG" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
# following does not force release libraries for wxWidgets using find_package
#set(CMAKE_MAP_IMPORTED_CONFIG_DEBUG RELEASE)
set(wxWidgets_ROOT_DIR $ENV{WXMSW3})
find_package(wxWidgets QUIET REQUIRED xrc webview stc richtext ribbon propgrid aui gl html qa adv core xml net base scintilla)
# message("All wxWidgets: " ${wxWidgets_LIBRARIES})
set(FOUND "false")
foreach(lib ${wxWidgets_LIBRARIES})
string(FIND ${lib} "optimized" INDEX)
string(FIND ${lib} "debug" INDEX2)
string(FIND ${lib} "wxWidgets" INDEX3)
if (INDEX GREATER_EQUAL 0) # skip once
set(FOUND "true")
continue()
elseif((INDEX2 LESS 0) AND (INDEX3 LESS 0))
set(FOUND "true")
endif()
if (${FOUND} STREQUAL "true")
set(FOUND "false")
message("lib: ${lib}")
list(APPEND WX_LIBS_LIST ${lib})
endif()
endforeach()
list(JOIN WX_LIBS_LIST ";" wxWidgets_LIBRARIES)
# message("Link Libraries for wxWidgets: ${wxWidgets_LIBRARIES}")
endif ()
if (wxWidgets_FOUND)
include(${wxWidgets_USE_FILE})
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${wxWidgets_CXX_FLAGS}")
if (UNIX AND NOT APPLE)
find_library(FONTCONFIG_LIBRARY NAMES fontconfig)
endif ()
if (MSVC)
find_package(OpenGL REQUIRED)
endif ()
#####################################################################################################################
#
# Project Settings
#
#####################################################################################################################
# for rapidjson folder
include_directories($ENV{RAPIDJSONDIR})
add_subdirectory(src)
if (NOT SAM_SKIP_TOOLS)
add_subdirectory(tools)
endif()