1 ########################################################
\r
3 # This is a CMake configuration file.
\r
4 # To use it you need CMake which can be
\r
5 # downloaded from here:
\r
6 # http://www.cmake.org/cmake/resources/software.html
\r
8 #########################################################
\r
10 cmake_minimum_required( VERSION 2.8 )
\r
12 # We use the lower case name
\r
13 # on UNIX systems other than Mac OS X
\r
14 if ( WIN32 OR APPLE )
\r
15 project( FlightCrew-gui )
\r
17 project( flightcrew-gui )
\r
20 #############################################################################
\r
22 find_package( Qt4 4.6.0 COMPONENTS QtCore QtGui QtMain QtNetwork REQUIRED )
\r
24 include( ${QT_USE_FILE} )
\r
26 #############################################################################
\r
28 file( GLOB_RECURSE RAW_SOURCES *.h *.cpp )
\r
30 set( QOBJECT_HEADERS
\r
39 # Runs MOC on specifed files
\r
40 qt4_wrap_cpp( MOC_FILES_CPP ${QOBJECT_HEADERS} )
\r
42 # Runs UIC on specified files
\r
43 qt4_wrap_ui( UI_FILES_H ${UI_FILES} )
\r
45 set( ALL_SOURCES ${RAW_SOURCES} ${MOC_FILES_CPP} ${UI_FILES_H} )
\r
47 #############################################################################
\r
49 # Apple bundle configuration
\r
51 # Copy the PLIST file...
\r
52 exec_program( "cp ${PROJECT_SOURCE_DIR}/resources/mac/MacOSXBundleInfo.plist ${PROJECT_BINARY_DIR}")
\r
54 # ...and set the FlightCrew version string
\r
55 exec_program( "sed -i -e 's/FCVERSION/${FLIGHTCREW_FULL_VERSION}/g' ${PROJECT_BINARY_DIR}/MacOSXBundleInfo.plist")
\r
58 #############################################################################
\r
60 # Creating source groups for VS, Xcode
\r
61 include( ${CMAKE_SOURCE_DIR}/cmake_extras/FileSystemSourceGroups.cmake )
\r
62 create_source_groups( RAW_SOURCES )
\r
64 #############################################################################
\r
66 # We need to pick up the stdafx.h file
\r
67 # and the headers for the linked-to libraries
\r
68 include_directories( ${CMAKE_CURRENT_SOURCE_DIR}
\r
69 ${CMAKE_CURRENT_BINARY_DIR}
\r
70 ${BoostParts_SOURCE_DIR}
\r
71 ${FlightCrew_SOURCE_DIR}
\r
72 ${XercesExtensions_SOURCE_DIR}
\r
75 #############################################################################
\r
77 # We make bundles for Mac OS X
\r
79 add_executable( ${PROJECT_NAME} MACOSX_BUNDLE ${ALL_SOURCES} )
\r
80 set_target_properties( ${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_BINARY_DIR}/MacOSXBundleInfo.plist )
\r
81 # ...and a normal executable for everything else.
\r
83 add_executable( ${PROJECT_NAME} WIN32 ${ALL_SOURCES} )
\r
86 target_link_libraries( ${PROJECT_NAME} FlightCrew ${QT_LIBRARIES} )
\r
88 #############################################################################
\r
90 if( BUILD_SHARED_FC )
\r
91 add_definitions( -DFC_BUILT_AS_DLL )
\r
94 #############################################################################
\r
96 # "Link time code generation" flags for MSVC
\r
97 # TODO: split into special cmake file
\r
99 # We'd love to use /W4 here, but there's just so much
\r
100 # noise coming from Qt it's absurd
\r
101 add_definitions( /DUNICODE /D_UNICODE )
\r
103 set_source_files_properties( MainWindow.cpp PROPERTIES COMPILE_DEFINITIONS /W4 )
\r
104 set_source_files_properties( main.cpp PROPERTIES COMPILE_DEFINITIONS /W4 )
\r
106 set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-" )
\r
107 set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Oi /GL" )
\r
108 set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG" )
\r
110 # "Print all warnings" flag for GCC
\r
111 elseif( CMAKE_COMPILER_IS_GNUCXX )
\r
112 add_definitions( -Wall )
\r
115 set_source_files_properties( MainWindow.cpp PROPERTIES COMPILE_DEFINITIONS FLIGHTCREW_FULL_VERSION="${FLIGHTCREW_FULL_VERSION}" )
\r
116 set_source_files_properties( UpdateChecker.cpp PROPERTIES COMPILE_DEFINITIONS FLIGHTCREW_FULL_VERSION="${FLIGHTCREW_FULL_VERSION}" )
\r
118 #############################################################################
\r
120 # For Mac, add frameworks and make a DMG
\r
122 if(CMAKE_GENERATOR STREQUAL Xcode)
\r
123 set( WORK_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release" )
\r
125 set( WORK_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" )
\r
128 add_custom_target( addframeworks ALL
\r
129 COMMAND ${QT_BINARY_DIR}/macdeployqt FlightCrew-gui.app
\r
130 WORKING_DIRECTORY ${WORK_DIR}
\r
131 DEPENDS ${PROJECT_NAME} )
\r
133 add_custom_target( makedmg
\r
134 COMMAND ${QT_BINARY_DIR}/macdeployqt FlightCrew-gui.app -dmg -no-plugins
\r
135 WORKING_DIRECTORY ${WORK_DIR}
\r
136 DEPENDS addframeworks )
\r
138 # For Linux and Windows, provide binary installers.
\r
139 # For this to work on Linux, InstallJammer needs to be installed and on the system path.
\r
140 # For this to work on Windows, Inno Setup's iscc compiler needs to be installed and on the system path.
\r
142 set( TEMP_PACKAGE_DIR ${CMAKE_BINARY_DIR}/temp_folder )
\r
143 set( MAIN_PACKAGE_DIR ${TEMP_PACKAGE_DIR}/FlightCrew )
\r
144 set( OUTPUT_PACKAGE_DIR ${CMAKE_BINARY_DIR}/installer )
\r
146 # MPI (InstallJammer) file will need to be copied to this location
\r
147 set( MPI_LOCATION ${CMAKE_BINARY_DIR}/temp_folder/FlightCrew.mpi )
\r
149 # ISS conf file for the Inno Setup compiler
\r
150 # We first create a CMake configured version of the ISS file,
\r
151 # and then we copy it to the temp folder every time we need to build the installer.
\r
152 set( ISS_MAIN_LOCATION ${CMAKE_SOURCE_DIR}/installer/FlightCrew.iss )
\r
153 Set( ISS_OC_LOCATION ${CMAKE_SOURCE_DIR}/OpenCandy/FlightCrewOC.iss )
\r
154 set( ISS_CONFIGURED_LOCATION ${CMAKE_BINARY_DIR}/FlightCrew_configured.iss )
\r
155 set( ISS_TEMP_LOCATION ${CMAKE_BINARY_DIR}/temp_folder/FlightCrew_configured.iss )
\r
157 if ( 64_BIT_PLATFORM )
\r
158 # Used in the ISS CMake configuration
\r
159 set( ISS_ARCH "x64" )
\r
160 set( ISS_SETUP_FILENAME_PLATFORM "-x64" )
\r
163 # This is used to build OpenCandy installers. You can't build them
\r
164 # from the source repo and you shouldn't want to either. By default,
\r
165 # vanilla installers are built. You want the vanillas.
\r
166 if ( EXISTS ${ISS_OC_LOCATION} )
\r
167 set( OC_INSTALLERS TRUE )
\r
170 # Creates a copy of the ISS file in ${ISS_CONFIGURED_LOCATION} and then configures it
\r
171 if ( OC_INSTALLERS )
\r
172 set( LICENSE_LOCATION ${CMAKE_SOURCE_DIR}/OpenCandy/win_installer_note.txt )
\r
173 configure_file( ${ISS_OC_LOCATION} ${ISS_CONFIGURED_LOCATION} )
\r
175 set( LICENSE_LOCATION ${CMAKE_SOURCE_DIR}/installer/win_installer_note.txt )
\r
176 configure_file( ${ISS_MAIN_LOCATION} ${ISS_CONFIGURED_LOCATION} )
\r
179 # Specify platform var for installjammer
\r
181 set( PLATFORM "Windows" )
\r
183 if ( 64_BIT_PLATFORM )
\r
184 set( PLATFORM "Linux-x86_64" )
\r
186 set( PLATFORM "Linux-x86" )
\r
190 # We use Inno for the Windows installers and InstallJammer for the Linux ones
\r
192 # Run Inno Setup's iscc compiler (*AFTER* all the PRE_BUILD custom commands execute)
\r
193 add_custom_target( makeinstaller
\r
194 COMMAND cmake -E echo "For this to work, Inno Setup's iscc compiler needs to be installed and on the system path."
\r
195 COMMAND iscc ${ISS_TEMP_LOCATION} )
\r
197 # Run InstallJammer (*AFTER* all the PRE_BUILD custom commands execute)
\r
198 add_custom_target( makeinstaller
\r
199 COMMAND cmake -E echo "For this to work, InstallJammer needs to be installed and on the system path."
\r
200 COMMAND installjammer -DBaseDir ${MAIN_PACKAGE_DIR}
\r
201 -DFCMajorVersion ${FLIGHTCREW_MAJOR_VERSION}
\r
202 -DFCMinorVersion ${FLIGHTCREW_MINOR_VERSION}
\r
203 -DFCRevisionVersion ${FLIGHTCREW_REVISION_VERSION}
\r
204 --platform ${PLATFORM}
\r
205 --output-dir ${OUTPUT_PACKAGE_DIR}
\r
206 --build-for-release
\r
208 --build ${MPI_LOCATION} )
\r
211 # We need to copy the files that will be used to make the installer to
\r
212 # a temporary directory. On the MSVC compiler the PRE_BUILD custom commands
\r
213 # can be added directly, but on other generators we need an intermediate target
\r
214 # since the PRE_BUILD condition is not supported. Using the intermediate for
\r
215 # MSVC makes it unnecessarily recompile that target every time the project is built.
\r
216 # So we use the direct way on MSVC, and the intemediate way for other generators.
\r
218 set( TARGET_FOR_COPY makeinstaller )
\r
219 add_dependencies( makeinstaller ${PROJECT_NAME} )
\r
221 set( TARGET_FOR_COPY copyfiles )
\r
223 # The intermediate target for copying
\r
224 add_custom_target( copyfiles
\r
225 COMMENT "Copying installer files to temporary location..."
\r
226 DEPENDS ${PROJECT_NAME} )
\r
228 add_dependencies( makeinstaller copyfiles )
\r
231 if ( WIN32 OR APPLE )
\r
232 set( FC_CLI_NAME FlightCrew-cli )
\r
234 set( FC_CLI_NAME flightcrew-cli )
\r
237 # We want to include the CLI in the installer, so it has to be built
\r
238 add_dependencies( makeinstaller ${FC_CLI_NAME} )
\r
240 # Copy MPI file to temp folder location
\r
241 add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD
\r
242 COMMAND cmake -E copy ${CMAKE_SOURCE_DIR}/installer/FlightCrew.mpi ${MPI_LOCATION} )
\r
244 # Copy ISS file to temp folder location
\r
245 add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD
\r
246 COMMAND cmake -E copy ${ISS_CONFIGURED_LOCATION} ${ISS_TEMP_LOCATION} )
\r
248 # Copy Qt runtime libs
\r
249 set( QT_LIBS QtCore QtGui QtNetwork )
\r
252 # DBus is needed on Linux
\r
253 list( APPEND QT_LIBS QtDBus )
\r
256 add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD COMMAND cmake -E make_directory ${MAIN_PACKAGE_DIR}/ )
\r
257 foreach( lib ${QT_LIBS} )
\r
258 set( location location-NOTFOUND )
\r
259 find_file( location ${lib} NAMES ${lib}4.dll lib${lib}.so.4 PATHS ${QT_LIBRARY_DIR} )
\r
260 add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD COMMAND cmake -E copy ${location} ${MAIN_PACKAGE_DIR}/ )
\r
263 # Set the path of the application executable
\r
265 set( EXE_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX} )
\r
266 set( CLI_EXE_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release/${FC_CLI_NAME}${CMAKE_EXECUTABLE_SUFFIX} )
\r
268 set( EXE_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX} )
\r
269 set( CLI_EXE_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${FC_CLI_NAME}${CMAKE_EXECUTABLE_SUFFIX} )
\r
272 # Copy the application executable
\r
273 add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD
\r
274 COMMAND cmake -E copy ${EXE_PATH} ${MAIN_PACKAGE_DIR} )
\r
276 # Copy the CLI application executable
\r
277 add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD
\r
278 COMMAND cmake -E copy ${CLI_EXE_PATH} ${MAIN_PACKAGE_DIR} )
\r
280 # We need to copy the CRT dlls
\r
282 # Add -DWIN_INSTALLER_USE_64BIT_CRT=1 to the cmake call if you want to build
\r
283 # an installer for the x64 verison of Sigil. This will make sure that the
\r
284 # correct CRT libs are included in the installer.
\r
285 if ( WIN_INSTALLER_USE_64BIT_CRT )
\r
286 message( STATUS "Using the 64 bit CRT in the FlightCrew Windows installer" )
\r
287 add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD
\r
288 COMMAND cmake -E copy ${CMAKE_SOURCE_DIR}/installer/msvc_crt/x64/msvcp100.dll ${MAIN_PACKAGE_DIR} )
\r
289 add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD
\r
290 COMMAND cmake -E copy ${CMAKE_SOURCE_DIR}/installer/msvc_crt/x64/msvcr100.dll ${MAIN_PACKAGE_DIR} )
\r
292 message( STATUS "Using the 32 bit CRT in the FlightCrew Windows installer" )
\r
293 add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD
\r
294 COMMAND cmake -E copy ${CMAKE_SOURCE_DIR}/installer/msvc_crt/x86/msvcp100.dll ${MAIN_PACKAGE_DIR} )
\r
295 add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD
\r
296 COMMAND cmake -E copy ${CMAKE_SOURCE_DIR}/installer/msvc_crt/x86/msvcr100.dll ${MAIN_PACKAGE_DIR} )
\r
301 # Copy the Unix launcher that adds the working directory to the LD_LIBRARY_PATH
\r
302 add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD
\r
303 COMMAND cmake -E copy ${PROJECT_SOURCE_DIR}/resources/bash/flightcrew-gui.sh ${MAIN_PACKAGE_DIR} )
\r
306 # Copy the Changelog
\r
307 add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD
\r
308 COMMAND cmake -E copy ${CMAKE_SOURCE_DIR}/ChangeLog.txt ${MAIN_PACKAGE_DIR} )
\r
310 # Copy the license files
\r
311 add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD
\r
312 COMMAND cmake -E copy ${CMAKE_SOURCE_DIR}/COPYING.txt ${MAIN_PACKAGE_DIR} )
\r
313 add_custom_command( TARGET ${TARGET_FOR_COPY} PRE_BUILD
\r
314 COMMAND cmake -E copy ${CMAKE_SOURCE_DIR}/COPYING.LESSER.txt ${MAIN_PACKAGE_DIR} )
\r
316 # Remove the temp directory used for building the installer
\r
317 add_custom_command( TARGET makeinstaller POST_BUILD
\r
318 COMMAND cmake -E remove_directory ${TEMP_PACKAGE_DIR}
\r
319 COMMENT "Removing temporary directory..." )
\r
322 #############################################################################
\r
324 # You can change the install location by
\r
325 # running cmake like this:
\r
327 # cmake -DCMAKE_INSTALL_PREFIX=/new/install/prefix
\r
329 # By default, the prefix is "/usr/local"
\r
331 if( UNIX AND NOT APPLE )
\r
332 install( TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin )
\r