-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
173 lines (142 loc) · 6.5 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
cmake_minimum_required(VERSION 3.10.0)
# Setup VERSION from VERSION.txt
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/scone/VERSION.txt" SCONE_VERSION_FULL)
string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" SCONE_VERSION ${SCONE_VERSION_FULL})
string(REGEX MATCH "-.+" SCONE_VERSION_POSTFIX ${SCONE_VERSION_FULL})
project(scone-studio VERSION ${SCONE_VERSION})
# Set LINUX variable
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
endif()
# Change default MSVC flags
if (MSVC)
string(REPLACE "/Ob2" "/Ob3" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
string(REPLACE "/Ob2" "/Ob3" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
endif()
# scone-studio options
option(SCONE_STUDIO_CPACK "Build SCONE Studio installer using CPack" OFF)
if (WIN32)
option(SCONE_STUDIO_CPACK_LOCAL "Create SCONE installer that installs to local AppData folder" OFF)
endif()
if (LINUX)
option(SCONE_STUDIO_CPACK_DEBIAN "Build debian installer using CPack" OFF)
endif()
if(SCONE_STUDIO_CPACK)
# file (STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/scone/.version" SCONE_REPOSITORY_REVISION)
# set(CPACK_PACKAGE_VERSION "${CMAKE_PROJECT_VERSION}.${SCONE_REPOSITORY_REVISION}")
set(CPACK_PACKAGE_VERSION "${SCONE_VERSION_FULL}")
endif()
# To create a folder hierarchy within Visual Studio.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# compilation database for completion on Linux
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Place build products (libraries, executables) in root
# binary (build) directory. Otherwise, they get scattered around
# the build directory and so the dll's aren't next to the executables.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
# set CMAKE_INSTALL_BINDIR etc.
include(GNUInstallDirs)
# Set INSTALL directories
if(LINUX)
set(CMAKE_INSTALL_RPATH "\$ORIGIN")
elseif(APPLE)
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
endif()
# Initialize LINUX settings from build script
if(LINUX)
# set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install")
if(NOT DEFINED OSG_DIR)
set(OSG_DIR "${CMAKE_SOURCE_DIR}/OpenSceneGraph/install")
list(APPEND CMAKE_PREFIX_PATH "${OSG_INSTALL_PATH}/lib64")
endif()
if(NOT DEFINED OPENSIM_INSTALL_DIR)
set(OPENSIM_INSTALL_DIR "${PROJECT_DIR}/opensim3-scone/install")
endif()
if(NOT DEFINED OPENSIM_INCLUDE_DIR)
set(OPENSIM_INCLUDE_DIR "${PROJECT_DIR}/opensim3-scone/install/sdk/include")
endif()
endif()
#
# Add targets
#
add_subdirectory(scone)
# Required packages
find_package(Qt5 COMPONENTS Widgets OpenGL PrintSupport REQUIRED)
add_subdirectory(submodules/vis)
add_subdirectory(src/sconestudio)
enable_testing()
#
# Installation / packaging (CPack)
#
if (SCONE_STUDIO_CPACK)
# package any required system libraries
include(InstallRequiredSystemLibraries)
# set necessary CPack variables
set(CPACK_PACKAGE_NAME "scone")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_VENDOR "Goatstream")
set(CPACK_PACKAGE_CONTACT "[email protected]")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://goatstream.com")
set(CPACK_PACKAGE_DESCRIPTION "A tool for predictive musculoskeletal simulations")
set(CPACK_PACKAGE_EXECUTABLES "sconestudio;SCONE Command Line Interface")
set(CPACK_OUTPUT_FILE_PREFIX "./../packages")
# install scenarios
install(DIRECTORY "${CMAKE_SOURCE_DIR}/scone/scenarios/Examples2" DESTINATION "./scone/scenarios")
install(DIRECTORY "${CMAKE_SOURCE_DIR}/scone/scenarios/Examples3" DESTINATION "./scone/scenarios")
install(DIRECTORY "${CMAKE_SOURCE_DIR}/scone/scenarios/Tutorials2" DESTINATION "./scone/scenarios")
install(DIRECTORY "${CMAKE_SOURCE_DIR}/scone/scenarios/Tutorials3" DESTINATION "./scone/scenarios")
install(DIRECTORY "${CMAKE_SOURCE_DIR}/scone/scenarios/Benchmarks" DESTINATION "./scone/scenarios")
install(DIRECTORY "${CMAKE_SOURCE_DIR}/scone/scenarios/SconePy" DESTINATION "./scone/scenarios")
install(DIRECTORY "${CMAKE_SOURCE_DIR}/resources" DESTINATION ".")
# Windows install/packaging:
if (WIN32)
# packaging: use NSIS to package everything into a self-extracting installer
set(CPACK_PACKAGE_NAME "SCONE")
set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_SOURCE_DIR}/packages")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "SCONE")
set(CPACK_GENERATOR NSIS)
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/scone/resources/package/scone_icon_24.ico")
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/scone/resources/package/scone_icon_24.ico")
# set(CPACK_NSIS_HELP_LINK ${CPACK_PACKAGE_HOMEPAGE_URL})
set(CPACK_NSIS_CONTACT "[email protected]")
set(CPACK_NSIS_MODIFY_PATH OFF)
set(CPACK_NSIS_IGNORE_LICENSE_PAGE ON)
if (SCONE_STUDIO_CPACK_LOCAL)
set(CPACK_NSIS_DEFINES "RequestExecutionLevel user")
set(CPACK_NSIS_INSTALL_ROOT "$LOCALAPPDATA")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}-Local")
set(CPACK_NSIS_DISPLAY_NAME "SCONE (Local)")
set(CPACK_NSIS_UNINSTALL_NAME "Uninstall SCONE Studio (Local)")
set(CPACK_NSIS_CREATE_ICONS "CreateShortCut '\$SMPROGRAMS\\\\SCONE (Local)\\\\SCONE Studio (Local).lnk' '\$INSTDIR\\\\bin\\\\sconestudio.exe'")
set(CPACK_NSIS_DELETE_ICONS_EXTRA "Delete '\$SMPROGRAMS\\\\SCONE (Local)\\\\SCONE Studio (Local).lnk'")
else()
set(CPACK_NSIS_UNINSTALL_NAME "Uninstall SCONE Studio")
set(CPACK_NSIS_CREATE_ICONS "CreateShortCut '\$SMPROGRAMS\\\\SCONE\\\\SCONE Studio.lnk' '\$INSTDIR\\\\bin\\\\sconestudio.exe'")
set(CPACK_NSIS_DELETE_ICONS_EXTRA "Delete '\$SMPROGRAMS\\\\SCONE\\\\SCONE Studio.lnk'")
endif()
endif()
if (UNIX AND NOT APPLE)
# packaging: package installation as archive
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
if (SCONE_STUDIO_CPACK_DEBIAN)
# packaging: package installation as a DEB
set(CPACK_GENERATOR DEB)
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/scone")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libstdc++6, zlib1g, freeglut3, qtbase5-dev, libpng16-16")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_STRIP_FILES YES)
# packaging: configure a script that creates symlinks /usr/local/bin/ --> /opt/scone/bin/
configure_file("${PROJECT_SOURCE_DIR}/tools/postinst.in" "postinst" @ONLY)
# packaging: configure a script that destroys the above symlink on uninstall
configure_file("${PROJECT_SOURCE_DIR}/tools/postrm.in" "postrm" @ONLY)
# packaging: tell debian packager to use the scripts for postinst and postrm actions
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_BINARY_DIR}/postinst;${CMAKE_BINARY_DIR}/postrm")
else()
set(CPACK_PACKAGING_INSTALL_PREFIX "/scone")
set(CPACK_GENERATOR TGZ)
endif()
endif()
# CPack vars etc. now fully configured, so include it
include(CPack)
endif()