-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
257 lines (213 loc) · 9.65 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
cmake_minimum_required(VERSION 3.8.2)
project( OpenGLCheckWithQt )
SET( PROJECT_VERSION_MAJOR 1 )
SET( PROJECT_VERSION_MINOR 0 )
SET( PROJECT_VERSION_PATCH 0 )
SET( PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}" CACHE STRING "The project version" FORCE )
# Find includes in the build directories
# Turn on automatic invocation of the MOC, UIC & RCC
# set(CMAKE_AUTOMOC ON)
# set(CMAKE_AUTOUIC ON)
# set(CMAKE_AUTORCC ON)
# There may be a way to tell up front if Qt5 is going to be found, but I haven't found
# a foolproof way to do it yet, so settle for the default error message for now.
#if(NOT CMAKE_PREFIX_PATH AND NOT Qt5Widgets_DIR)
# message(WARNING "CMAKE_PREFIX_PATH is not defined, so find_package may not work. Set the CMAKE_PREFIX_PATH "
# "environment variable to the install prefix of Qt 5, either on the command line as "
# "-DCMAKE_PREFIX_PATH=\"path/to/Qt5/lib/cmake\" or with set(CMAKE_PREFIX_PATH path/to/Qt5/lib/cmake)")
#endif(NOT CMAKE_PREFIX_PATH AND NOT Qt5Widgets_DIR)
# Add a compiler flag
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
SET( QT_VERSION "5.12.1" CACHE STRING "Superbuild Qt version to build CaPTk against" FORCE )
# Find the QtWidgets library
FIND_PACKAGE( Qt5Core ${QT_VERSION} )
IF( Qt5Core_FOUND OR (EXISTS ${PROJECT_BINARY_DIR}/qt/${QT_VERSION}/lib/cmake/Qt5/Qt5Config.cmake) )
IF (APPLE) # THIS QT FOLDER STRUCTURE WAS NOT REQUIRED FOR 5.11.2
SET( ENV{PATH} "${PROJECT_BINARY_DIR}/qt/${QT_VERSION}/clang_64/lib/cmake/Qt5/:${PROJECT_BINARY_DIR}/qt/${QT_VERSION}/clang_64/bin:$ENV{PATH}" CACHE PATH "" FORCE)
SET( ENV{CMAKE_PREFIX_PATH} "${PROJECT_BINARY_DIR}/qt/${QT_VERSION}/clang_64/lib/cmake/Qt5/:${PROJECT_BINARY_DIR}/qt/${QT_VERSION}/clang_64/bin:$ENV{CMAKE_PREFIX_PATH}" CACHE PATH "" FORCE )
SET( ENV{CMAKE_PROGRAM_PATH} "${PROJECT_BINARY_DIR}/qt/${QT_VERSION}/clang_64/lib/cmake/Qt5/:${PROJECT_BINARY_DIR}/qt/${QT_VERSION}/clang_64/bin:$ENV{CMAKE_PROGRAM_PATH}" CACHE PATH "" FORCE )
ELSE()
SET( ENV{CMAKE_PREFIX_PATH} "${PROJECT_BINARY_DIR}/qt/${QT_VERSION}/lib/cmake/Qt5/:${PROJECT_BINARY_DIR}/qt/${QT_VERSION}/bin:$ENV{CMAKE_PREFIX_PATH}" CACHE PATH "" FORCE )
SET( ENV{LD_LIBRARY_PATH} "${QT_EXTRACTED_DIR}/${QT_VERSION}/lib/:$ENV{LD_LIBRARY_PATH}" CACHE PATH "" FORCE )
SET( ENV{CMAKE_PROGRAM_PATH} "${PROJECT_BINARY_DIR}/qt/${QT_VERSION}/lib/cmake/Qt5/:${PROJECT_BINARY_DIR}/qt/${QT_VERSION}/bin:$ENV{CMAKE_PROGRAM_PATH}" CACHE PATH "" FORCE )
SET( ENV{PATH} "${PROJECT_BINARY_DIR}/qt/${QT_VERSION}/lib/cmake/Qt5/:${PROJECT_BINARY_DIR}/qt/${QT_VERSION}/bin:$ENV{PATH}" CACHE PATH "" FORCE)
ENDIF()
ELSE()
INCLUDE( cmake_modules/External-Qt.cmake )
ENDIF()
IF( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
IF( WIN32 )
SET( CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/install CACHE PATH "Changed the default install path" FORCE )
INSTALL(FILES "${DATA_DIR}/qt.conf" DESTINATION bin)
ELSEIF( APPLE )
# do nothing
ELSE()
SET( CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/install/appdir/usr CACHE PATH "Changed the default install path" FORCE )
ENDIF()
ENDIF( )
# Make this a GUI application on Windows
if(WIN32)
set(CMAKE_WIN32_EXECUTABLE ON)
endif()
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake_modules/)
INCLUDE_DIRECTORIES( src )
FIND_PACKAGE(Qt5 COMPONENTS Core Gui Svg Widgets WebView WebEngine WebEngineCore WebEngineWidgets Concurrent Test Sql REQUIRED)
# For some reason IF(LINUX) doesn't work properly on linux
# This is necessary for the whole project to compile on linux
IF(WIN32)
ELSEIF(APPLE)
ELSE()
FIND_PACKAGE(Qt5 COMPONENTS X11Extras REQUIRED)
ENDIF()
find_package(OpenGL)
LINK_DIRECTORIES(${QT_LIBRARY_DIR})
#INCLUDE(${QT_USE_FILE})
SET(QT_USE_QTGUI TRUE)
SET(QT_USE_QTMAIN TRUE)
SET(QT_USE_QTGUI TRUE)
ADD_DEFINITIONS(${QT_DEFINITIONS})
ADD_DEFINITIONS(-DQT_PLUGIN)
ADD_DEFINITIONS(-DQT_THREAD_SUPPORT)
LINK_DIRECTORIES(${QT_LIBRARY_DIR})
# link dependent libraries
SET( DEPENDENT_LIBS
Qt5::Core
Qt5::Gui
Qt5::Svg
Qt5::Widgets
Qt5::WebView
Qt5::WebEngine
Qt5::WebEngineCore
Qt5::WebEngineWidgets
Qt5::Concurrent
Qt5::Test
Qt5::Sql
${OPENGL_LIBRARIES}
)
IF(UNIX AND NOT APPLE)
SET( DEPENDENT_LIBS
${DEPENDENT_LIBS}
Qt5::X11Extras
)
ENDIF()
# Tell CMake to create the helloworld executable
set( SOURCES ${PROJECT_SOURCE_DIR}/src/main.cxx ${PROJECT_SOURCE_DIR}/src/CheckOpenGLVersion.h ${PROJECT_SOURCE_DIR}/src/CheckOpenGLVersion.cpp )
IF (APPLE)
SET (EXE_NAME "${PROJECT_NAME}_${PROJECT_VERSION}")
ELSE()
SET( EXE_NAME "${PROJECT_NAME}" )
ENDIF()
IF (APPLE)
set(OS_BUNDLE MACOSX_BUNDLE)
# Identify MacOS bundle
SET(MACOSX_BUNDLE_BUNDLE_NAME "${PROJECT_NAME}_${PROJECT_VERSION}")
SET(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION})
SET(MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION})
SET(MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION})
SET(MACOSX_BUNDLE_COPYRIGHT ${COPYRIGHT})
SET(MACOSX_BUNDLE_GUI_IDENTIFIER ${IDENTIFIER})
SET(MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
ADD_EXECUTABLE(${EXE_NAME}
${OS_BUNDLE}
${SOURCES}
)
ELSE()
ADD_EXECUTABLE(${EXE_NAME}
${SOURCES}
#${YAMLCPP_Headers}
#${YAMLCPP_Sources}
)
ENDIF()
# Add the Qt5 Widgets for linking
target_link_libraries(${EXE_NAME} ${DEPENDENT_LIBS} )
IF (APPLE)
INSTALL( TARGETS OpenGLCheckWithQt
BUNDLE DESTINATION .
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
# INSTALL(DIRECTORY "${PROJECT_BINARY_DIR}/${EXE_NAME}.app" DESTINATION .)
# INSTALL( FILES "${PROJECT_BINARY_DIR}/${EXE_NAME}.app/Contents/MacOS/${EXE_NAME}"
# DESTINATION ${EXE_NAME}.app/Contents/MacOS
# PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
# )
ELSE()
INSTALL( TARGETS OpenGLCheckWithQt
BUNDLE DESTINATION .
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
CONFIGURATIONS "${CMAKE_CONFIGURATION_TYPES}"
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
ENDIF()
if(APPLE)
SET (${PROJECT_NAME}_MACOSX_BUNDLE_NAME "${PROJECT_NAME}_${PROJECT_VERSION}")
SET (CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/${PROJECT}" )
endif()
# CPack settings
IF(WIN32)
SET(CPACK_GENERATOR NSIS)
SET(CPACK_SOURCE_GENERATOR "ZIP")
SET(CPACK_NSIS_DISPLAY_NAME "${PROJECT_NAME}")
SET(CPACK_NSIS_PACKAGE_NAME "${PROJECT_NAME}")
SET(CPACK_NSIS_INSTALL_ROOT "C:")
SET(CPACK_NSIS_DEFINES "RequestExecutionLevel user")
SET(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
SET(CPACK_NSIS_MUI_FINISHPAGE_RUN "${EXE_NAME}.exe")
#SET(CPACK_NSIS_MODIFY_PATH "ON") # desktop shortcut doesn't work, for some reason
# create extra shortcuts and respective uninstall targets
SET(CPACK_NSIS_CREATE_ICONS_EXTRA "CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\${EXE_NAME}.lnk' '\$INSTDIR\\\\bin\\\\${EXE_NAME}.exe'")
#SET(CPACK_NSIS_CREATE_ICONS "CreateShortCut '$DESKTOP\\\\${EXE_NAME}.lnk' '$INSTDIR\\\\bin\\\\${EXE_NAME}.exe'")
#SET(CPACK_NSIS_CREATE_ICONS_EXTRA " CreateShortCut '$INSTDIR\\\\${EXE_NAME}.lnk' '$INSTDIR\\\\bin\\\\${EXE_NAME}.exe'")
SET(CPACK_NSIS_CREATE_ICONS "CreateShortCut '\$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\README.lnk' '\$INSTDIR\\\\share\\\\doc\\\\index.html'")
#SET(CPACK_NSIS_DELETE_ICONS_EXTRA " Delete '$SMPROGRAMS\\\\$START_MENU\\\\${EXE_NAME}.lnk'")
SET(CPACK_NSIS_DELETE_ICONS "Delete '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\${EXE_NAME}.lnk'")
#SET(CPACK_NSIS_DELETE_ICONS "Delete '$DESKTOP\\\\${EXE_NAME}.lnk'")
#SET(CPACK_NSIS_DELETE_ICONS_EXTRA "Delete '$INSTDIR\\\\${EXE_NAME}.lnk'")
SET(CPACK_NSIS_DELETE_ICONS "Delete '$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\README.lnk'")
SET(CPACK_NSIS_INSTALLED_ICON_NAME "${EXE_NAME}")
SET(CPACK_SYSTEM_NAME "Win64")
ELSEIF(APPLE)
SET(CPACK_GENERATOR DragNDrop )
SET(CPACK_DMG_FORMAT "UDBZ")
SET(CPACK_DMG_VOLUME_NAME "${PROJECT_NAME}_${PROJECT_VERSION}")
SET(CPACK_BUNDLE_NAME "${PROJECT_NAME}_${PROJECT_VERSION}")
SET(CPACK_SYSTEM_NAME "OSX")
# SET(CPACK_STRIP_FILES "${EXE_NAME}")
# SET(CPACK_STRIP_FILES "${EXE_NAME}.app/Contents/MacOS/${EXE_NAME}")
ENDIF()
# common
SET(CPACK_SOURCE_STRIP_FILES TRUE )
SET(CPACK_PACKAGE_EXECUTABLES "${EXE_NAME}" "${EXE_NAME}")
SET(CPACK_CREATE_DESKTOP_LINKS "${EXE_NAME}" )
SET(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}_${PROJECT_VERSION}")
IF(WIN32)
SET(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}_${PROJECT_VERSION}_Installer")
ENDIF()
SET(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
SET(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Checking OpenGL version")
SET(CPACK_SOURCE_IGNORE_FILES "\\\\.svn/;^${PROJECT_SOURCE_DIR}/doc/")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "captk-${SW_VER}-source" CACHE INTERNAL "tarball basename")
SET(CPACK_COMPONENT_LIBRARIES_INSTALL_TYPES Developer Full)
SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
SET(CPACK_COMPONENT_APPLICATIONS_INSTALL_TYPES Full)
SET(CPACK_ALL_INSTALL_TYPES Full Developer)
SET(CPACK_SOURCE_IGNORE_FILES "${CMAKE_SOURCE_DIR}/bin/;{CMAKE_SOURCE_DIR}/build/;${CMAKE_SOURCE_DIR}/.svn/")
SET(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
SET(CMAKE_INSTALL_OPENMP_LIBRARIES TRUE)
INCLUDE(InstallRequiredSystemLibraries)
IF(WIN32)
INCLUDE(Windeployqt)
windeployqt(${EXE_NAME} bin)
ELSEIF(APPLE)
# INCLUDE(ChmodFile)
# chmodFile(${EXE_NAME} dcm2nii)
# chmodFile(${EXE_NAME} ITK-SNAP)
INCLUDE(Macdeployqt)
macdeployqt(${EXE_NAME})
ELSE()
# ITK HERE
ENDIF()
INCLUDE(CPack)