-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
175 lines (147 loc) · 5.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
174
175
cmake_minimum_required(VERSION 2.8.2)
# --------------------------------------------------------------------------
project(CTKResEdit)
#-----------------------------------------------------------------------------
# Set a default build type if none was specified
#
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Debug' as none was specified.")
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
#-----------------------------------------------------------------------------
# Version number.
#
set(CTKResEdit_MAJOR_VERSION 0)
set(CTKResEdit_MINOR_VERSION 1)
set(CTKResEdit_BUILD_VERSION 0)
set(CTKResEdit_VERSION_IS_RELEASE 0)
#set(CTKResEdit_VERSION_RC 1)
if(CTKResEdit_VERSION_IS_RELEASE)
set(CTKResEdit_VERSION_SOURCE "")
else()
include(${CMAKE_SOURCE_DIR}/CMake/ctkVersionSource.cmake)
endif()
# Compute the full version string.
set(CTKResEdit_VERSION
"${CTKResEdit_MAJOR_VERSION}.${CTKResEdit_MINOR_VERSION}.${CTKResEdit_BUILD_VERSION}")
if(CTKResEdit_VERSION_RC)
set(CTKResEdit_VERSION ${CTKResEdit_VERSION}-rc${CTKResEdit_VERSION_RC})
endif()
if(CTKResEdit_VERSION_SOURCE)
set(CTKResEdit_VERSION ${CTKResEdit_VERSION}-${CTKResEdit_VERSION_SOURCE})
endif()
message(STATUS "CTKResEdit version: ${CTKResEdit_VERSION}")
configure_file(
CMake/ctkResEditVersionConfig.h.in
${CMAKE_CURRENT_BINARY_DIR}/ctkResEditVersionConfig.h
)
#-----------------------------------------------------------------------------
# Install directories, used for install rules.
#
set(CTK_INSTALL_BIN_DIR "bin")
set(CTK_INSTALL_LIB_DIR "lib")
#-----------------------------------------------------------------------------
#
find_package(Qt4 4.7 REQUIRED)
include(${QT_USE_FILE})
set(ResEdit_SRCS
ctkCommandLineParser.cpp
ctkCommandLineParser.h
Main.cpp
)
set(ResEdit_MOC_SRCS
ctkCommandLineParser.h
)
QT4_WRAP_CPP(ResEditQt_SRCS ${ResEdit_MOC_SRCS})
# --------------------------------------------------------------------------
# Testing
#
include(CTest)
#-----------------------------------------------------------------------------
# Coverage
#
option(WITH_COVERAGE "Enable/Disable coverage" OFF)
#-----------------------------------------------------------------------------
# Set coverage Flags
#
if(WITH_COVERAGE)
if(CMAKE_CXX_COMPILER_ID AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(coverage_flags "-g -fprofile-arcs -ftest-coverage -O3 -DNDEBUG")
set(COVERAGE_C_FLAGS ${coverage_flags})
set(COVERAGE_CXX_FLAGS ${coverage_flags})
endif()
endif()
#-----------------------------------------------------------------------------
# ResEdit required C/CXX Flags
#
set(ResEdit_REQUIRED_C_FLAGS "${COVERAGE_C_FLAGS}")
set(ResEdit_REQUIRED_CXX_FLAGS "${COVERAGE_CXX_FLAGS}")
#-----------------------------------------------------------------------------
# Set C/CXX Flags
#
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ResEdit_REQUIRED_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ResEdit_C_REQUIRED_FLAGS}")
#-----------------------------------------------------------------------------
# Remove warning for not using the _s
if(MSVC)
add_definitions(
-D_CRT_SECURE_NO_WARNINGS
)
endif()
# --------------------------------------------------------------------------
# Include dirs
#
set(include_dirs
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
include_directories(${include_dirs})
# --------------------------------------------------------------------------
# Build executable
#
add_executable(${PROJECT_NAME} ${ResEdit_SRCS} ${ResEditQt_SRCS})
target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES})
# Install rules
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CTK_INSTALL_BIN_DIR} COMPONENT Runtime
LIBRARY DESTINATION ${CTK_INSTALL_LIB_DIR} COMPONENT Runtime
ARCHIVE DESTINATION ${CTK_INSTALL_LIB_DIR} COMPONENT Development)
# --------------------------------------------------------------------------
# Configure launcher
#
get_filename_component(QT_SHARED_LIBRARY_PATH_CONFIG ${QT_QMAKE_EXECUTABLE} PATH)
configure_file(
SetEnv.bat.in
${CMAKE_BINARY_DIR}/SetEnv.bat
)
set(CTKResEdit_LAUNCH_COMMAND ${CMAKE_BINARY_DIR}/SetEnv.bat)
# --------------------------------------------------------------------------
# Build Test
#
if(BUILD_TESTING)
add_subdirectory(Testing)
endif()
#-----------------------------------------------------------------------------
# Build a CPack installer if CPack is available and this is a build of just
# CTKResEdit (as opposed to a build of CTKResEdit included in some other project...)
if("${CTKResEdit_BINARY_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(CPACK_SYSTEM_NAME "win-i386")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CPACK_SYSTEM_NAME "win-amd64")
endif()
endif()
set(CPACK_MONOLITHIC_INSTALL ON)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME} - The Common Toolkit Application Launcher")
set(CPACK_PACKAGE_VENDOR "Kitware, Inc.")
#set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
#set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
set(CPACK_PACKAGE_VERSION "${CTKResEdit_VERSION}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME} ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
set(CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME}")
set(CPACK_GENERATOR "TGZ")
include(CPack)
endif()