forked from jasp-stats/jasp-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
187 lines (146 loc) · 5.31 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
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
cmake_minimum_required(VERSION 3.21)
# Because Qt implementation is a bit buggy,
# when this is fixed, the setup will be even nicer.
set(QT_CREATOR_SKIP_CONAN_SETUP ON)
# ------ Build Toolchain
if(APPLE)
execute_process(COMMAND uname -m OUTPUT_VARIABLE HOST_PROCESSOR OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Host processor is ${HOST_PROCESSOR}")
if("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
set(CMAKE_OSX_ARCHITECTURES ${HOST_PROCESSOR})
set(CROSS_COMPILING 0)
message(STATUS "Building for ${CMAKE_OSX_ARCHITECTURES} architecture")
else()
if(NOT ("${CMAKE_OSX_ARCHITECTURES}" STREQUAL "${HOST_PROCESSOR}"))
set(CROSS_COMPILING 1)
message(STATUS "Cross compiling for ${CMAKE_OSX_ARCHITECTURES} architecture")
endif()
endif()
if(CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0 CACHE STRING "Minimum macOS version the build will be able to run on" FORCE)
set(CONAN_ARCH "armv8")
else()
set(CMAKE_OSX_DEPLOYMENT_TARGET 12.0 CACHE STRING "Minimum macOS version the build will be able to run on" FORCE)
set(CONAN_ARCH "x86_64")
endif()
if("${CMAKE_OSX_SYSROOT}" STREQUAL "macosx" OR "${CMAKE_OSX_SYSROOT}" STREQUAL "")
execute_process(COMMAND xcrun --sdk macosx --show-sdk-path
OUTPUT_VARIABLE SDKROOT
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_OSX_SYSROOT ${SDKROOT})
message(STATUS "Got CMAKE_OSX_SYSROOT from xcrun as '${SDKROOT}'")
else()
message(STATUS "CMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}")
endif()
endif()
project(
JASP
VERSION 0.18.3.0 # <major>[.<minor>[.<patch>[.<tweak>]]]
LANGUAGES CXX C
HOMEPAGE_URL "http://jasp-stats.org/"
DESCRIPTION "A fresh way to do statistics")
#needed for R-Interface and QMLComponents for them to build stuff porperly when *inside* JASP
add_definitions(-DBUILDING_JASP)
set(BUILDING_JASP TRUE)
set(CMAKE_MESSAGE_CONTEXT_SHOW ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_FIND_FRAMEWORK ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
"Debug"
CACHE STRING
"OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]" FORCE)
message(STATUS "Building for ${CMAKE_BUILD_TYPE}")
endif()
# ------ CMake Modules
include(FetchContent)
include(ExternalProject)
include(CMakePrintHelpers)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/Tools/CMake")
# ------ Options
include(Config)
# ------ Conan Dependency Manager
include(Conan)
# ------ JASP Config
# Looking for programs, e.g., git, bison, flex
include(Programs)
# Looking for libraries, e.g., Boost, Qt
include(Libraries)
# Preparing irregular dependencies, e.g., ReadStat
include(Dependencies)
# Setting JASP's parameters, e.g., JASP_VERSION
include(JASP)
# Preparing R environment, and setting R_HOME_PATH
include(R)
# These tell Qt to do its things
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
# Later, I would try tor remove this, for now, it's necessary because Conan
# tends to mess up the directory structure
if(WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO
${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL
${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
add_subdirectory(Common)
add_subdirectory(CommonData)
add_subdirectory(QMLComponents)
if(NOT WIN32)
add_subdirectory(R-Interface)
else()
# Building R-Interface with MinGW configuration, see R-Interface/CMakeLists.txt
# for more info. Note that the build path is set to be inside the JASP's build
# folder, e.g. jasp-desktop-build-dir/R-Interface
add_custom_target(
R-Interface
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/R-Interface
BYPRODUCTS ${CMAKE_BINARY_DIR}/R-Interface/libR-Interface.dll
${CMAKE_BINARY_DIR}/R-Interface/libR-Interface.dll.a
COMMAND
${CMAKE_COMMAND} -G "MinGW Makefiles" -S . -B
${CMAKE_BINARY_DIR}/R-Interface "-DRTOOLS_PATH:PATH=${RTOOLS_PATH}"
"-DCMAKE_C_COMPILER:PATH=${RTOOLS_C_COMPILER}"
"-DCMAKE_CXX_COMPILER:PATH=${RTOOLS_CXX_COMPILER}"
"-DCMAKE_MAKE_PROGRAM:PATH=${RTOOLS_MAKE_PROGRAM}"
"-DJASP_BINARY_DIR:PATH=${CMAKE_BINARY_DIR}"
"-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
"-DR_VERSION:STRING=${R_VERSION}"
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/R-Interface
USES_TERMINAL
COMMENT "------ Configuring and Building the libR-Interface")
endif()
add_subdirectory(Engine)
add_subdirectory(Desktop)
if(BUILD_TESTS)
enable_testing()
add_subdirectory(Tests)
endif()
# Builds, installs and configures JASP Modules
include(Modules)
# Install logic, usually staging a deploy-able JASP in Build/Install/ folder
include(Install)
# Packs and creates installer executable for Windows, and macOS
if(NOT LINUX)
if("${NIGHTLY_BUILD}" STREQUAL "ON")
SET(MACOS_JENKINS_SKIPPER "--skip-jenkins")
else()
SET(MACOS_JENKINS_SKIPPER "")
endif()
include(Pack)
endif()
if(NOT
CMAKE_GENERATOR
STREQUAL
"Ninja")
message(
WARNING
"JASP is optimised to be built using the Ninja build system. You have chosen ${CMAKE_GENERATOR}, and this might cause issue during the build."
)
endif()