From dd7b6642a3b171734126b6b4a14236cfe6406fcf Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Sun, 6 Apr 2014 19:43:09 +0200 Subject: Use the same style of CMake files everywhere --- mmc_updater/src/CMakeLists.txt | 161 +++++++++++++++++------------------ mmc_updater/src/tests/CMakeLists.txt | 18 ++-- 2 files changed, 87 insertions(+), 92 deletions(-) (limited to 'mmc_updater/src') diff --git a/mmc_updater/src/CMakeLists.txt b/mmc_updater/src/CMakeLists.txt index d1a32755..d27fbe00 100644 --- a/mmc_updater/src/CMakeLists.txt +++ b/mmc_updater/src/CMakeLists.txt @@ -4,79 +4,76 @@ add_subdirectory(tests) find_package(Threads REQUIRED) include(GenerateCppResourceFile) -set (UPDATER_SOURCES - AppInfo.cpp - AppInfo.h - DirIterator.cpp - DirIterator.h - FileUtils.cpp - FileUtils.h - Log.cpp - Log.h - ProcessUtils.cpp - ProcessUtils.h - StandardDirs.cpp - StandardDirs.h - UpdateDialog.cpp - UpdateInstaller.cpp - UpdateInstaller.h - UpdateScript.cpp - UpdateScript.h - UpdaterOptions.cpp - UpdaterOptions.h +set(UPDATER_SOURCES + AppInfo.cpp + AppInfo.h + DirIterator.cpp + DirIterator.h + FileUtils.cpp + FileUtils.h + Log.cpp + Log.h + ProcessUtils.cpp + ProcessUtils.h + StandardDirs.cpp + StandardDirs.h + UpdateDialog.cpp + UpdateInstaller.cpp + UpdateInstaller.h + UpdateScript.cpp + UpdateScript.h + UpdaterOptions.cpp + UpdaterOptions.h ) add_definitions(-DTIXML_USE_STL) -if (WIN32) +if(WIN32) set(UPDATER_SOURCES ${UPDATER_SOURCES} UpdateDialogWin32.cpp UpdateDialogWin32.h) endif() -if (UNIX) +if(UNIX) set(UPDATER_SOURCES ${UPDATER_SOURCES} UpdateDialogAscii.cpp UpdateDialogAscii.h) add_definitions(-Wall -Wconversion) -if (APPLE) - set(MAC_DOCK_ICON_CPP_FILE ${CMAKE_CURRENT_BINARY_DIR}/mac_dock_icon.cpp) - set(MAC_INFO_PLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/mac_info_plist.cpp) - generate_cpp_resource_file(resource_macdockicon ${CMAKE_CURRENT_SOURCE_DIR}/resources/mac.icns ${MAC_DOCK_ICON_CPP_FILE}) - generate_cpp_resource_file(resource_macplist ${CMAKE_CURRENT_SOURCE_DIR}/resources/Info.plist ${MAC_INFO_PLIST_FILE}) - set(UPDATER_SOURCES ${UPDATER_SOURCES} - MacBundle.h - MacBundle.cpp - StandardDirs.mm - StlSymbolsLeopard.cpp - UpdateDialogCocoa.mm - UpdateDialogCocoa.h - mac_dock_icon.cpp - mac_info_plist.cpp - ) -else() # linuxes and other similar systems - find_package(GTK2 REQUIRED gtk) - include_directories(${GTK2_INCLUDE_DIRS}) - add_library(updatergtk SHARED UpdateDialogGtk.cpp UpdateDialogGtk.h) - target_link_libraries(updatergtk ${GTK2_LIBRARIES}) - - # embed the GTK helper library into the updater binary. - # At runtime it will be extracted and loaded if the - # GTK libraries are available - get_property(GTK_UPDATER_LIB TARGET updatergtk PROPERTY LOCATION) - set(GTK_BIN_CPP_FILE ${CMAKE_CURRENT_BINARY_DIR}/libupdatergtk.cpp) - generate_cpp_resource_file(resource_updatergtk ${GTK_UPDATER_LIB} ${GTK_BIN_CPP_FILE}) - add_dependencies(resource_updatergtk updatergtk) - - set(UPDATER_SOURCES ${UPDATER_SOURCES} UpdateDialogGtkFactory.cpp UpdateDialogGtkFactory.h ${GTK_BIN_CPP_FILE}) -endif() + if(APPLE) + set(MAC_DOCK_ICON_CPP_FILE ${CMAKE_CURRENT_BINARY_DIR}/mac_dock_icon.cpp) + set(MAC_INFO_PLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/mac_info_plist.cpp) + generate_cpp_resource_file(resource_macdockicon ${CMAKE_CURRENT_SOURCE_DIR}/resources/mac.icns ${MAC_DOCK_ICON_CPP_FILE}) + generate_cpp_resource_file(resource_macplist ${CMAKE_CURRENT_SOURCE_DIR}/resources/Info.plist ${MAC_INFO_PLIST_FILE}) + set(UPDATER_SOURCES ${UPDATER_SOURCES} + MacBundle.h + MacBundle.cpp + StandardDirs.mm + StlSymbolsLeopard.cpp + UpdateDialogCocoa.mm + UpdateDialogCocoa.h + mac_dock_icon.cpp + mac_info_plist.cpp + ) + else() # linuxes and other similar systems + find_package(GTK2 REQUIRED gtk) + include_directories(${GTK2_INCLUDE_DIRS}) + add_library(updatergtk SHARED UpdateDialogGtk.cpp UpdateDialogGtk.h) + target_link_libraries(updatergtk ${GTK2_LIBRARIES}) + + # embed the GTK helper library into the updater binary. + # At runtime it will be extracted and loaded if the + # GTK libraries are available + get_property(GTK_UPDATER_LIB TARGET updatergtk PROPERTY LOCATION) + set(GTK_BIN_CPP_FILE ${CMAKE_CURRENT_BINARY_DIR}/libupdatergtk.cpp) + generate_cpp_resource_file(resource_updatergtk ${GTK_UPDATER_LIB} ${GTK_BIN_CPP_FILE}) + add_dependencies(resource_updatergtk updatergtk) + + set(UPDATER_SOURCES ${UPDATER_SOURCES} UpdateDialogGtkFactory.cpp UpdateDialogGtkFactory.h ${GTK_BIN_CPP_FILE}) + endif() endif() add_library(updatershared STATIC ${UPDATER_SOURCES}) -target_link_libraries(updatershared - anyoption - tinyxml -) +target_link_libraries(updatershared anyoption tinyxml) -if (UNIX) - if (APPLE) +if(UNIX) + if(APPLE) find_library(COCOA_LIBRARY Cocoa) find_library(SECURITY_LIBRARY Security) target_link_libraries(updatershared ${SECURITY_LIBRARY} ${COCOA_LIBRARY}) @@ -86,36 +83,34 @@ if (UNIX) target_link_libraries(updatershared pthread dl) endif() -if (WIN32) +if(WIN32) set(EXE_FLAGS WIN32 resources/updater.rc) endif() add_executable(updater ${EXE_FLAGS} main.cpp) -target_link_libraries(updater - updatershared -) +target_link_libraries(updater updatershared) #### Updater Executable #### -IF(WIN32) -INSTALL(TARGETS updater - BUNDLE DESTINATION . COMPONENT Runtime - LIBRARY DESTINATION . COMPONENT Runtime - RUNTIME DESTINATION . COMPONENT Runtime -) -ENDIF() -IF(UNIX) -IF(APPLE) -INSTALL(TARGETS updater - BUNDLE DESTINATION . COMPONENT Runtime - RUNTIME DESTINATION MultiMC.app/Contents/MacOS COMPONENT Runtime -) -ELSE() -INSTALL(TARGETS updater - BUNDLE DESTINATION . COMPONENT Runtime - RUNTIME DESTINATION bin COMPONENT Runtime -) -ENDIF() -ENDIF() +if(WIN32) + install(TARGETS updater + BUNDLE DESTINATION . COMPONENT Runtime + LIBRARY DESTINATION . COMPONENT Runtime + RUNTIME DESTINATION . COMPONENT Runtime + ) +endif() +if(UNIX) + if(APPLE) + install(TARGETS updater + BUNDLE DESTINATION . COMPONENT Runtime + RUNTIME DESTINATION MultiMC.app/Contents/MacOS COMPONENT Runtime + ) + else() + install(TARGETS updater + BUNDLE DESTINATION . COMPONENT Runtime + RUNTIME DESTINATION bin COMPONENT Runtime + ) + endif() +endif() diff --git a/mmc_updater/src/tests/CMakeLists.txt b/mmc_updater/src/tests/CMakeLists.txt index 08501a98..5a96d7c9 100644 --- a/mmc_updater/src/tests/CMakeLists.txt +++ b/mmc_updater/src/tests/CMakeLists.txt @@ -1,8 +1,8 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/..") -if (APPLE) - set(HELPER_SHARED_SOURCES ../StlSymbolsLeopard.cpp) +if(APPLE) + set(HELPER_SHARED_SOURCES ../StlSymbolsLeopard.cpp) endif() # # Create helper binaries for unit tests @@ -17,14 +17,14 @@ endif() # Install data files required by unit tests set(TEST_FILES - file_list.xml + file_list.xml ) foreach(TEST_FILE ${TEST_FILES}) - execute_process( - COMMAND - "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" - ) + execute_process( + COMMAND + "${CMAKE_COMMAND}" -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/${TEST_FILE}" "${CMAKE_CURRENT_BINARY_DIR}" + ) endforeach() # Add unit test binaries @@ -32,13 +32,13 @@ macro(ADD_UPDATER_TEST CLASS) set(TEST_TARGET updater_${CLASS}) unset(srcs) list(APPEND srcs ${CLASS}.cpp) - if (WIN32) + if(WIN32) list(APPEND srcs ${CMAKE_CURRENT_SOURCE_DIR}/test.rc) endif() add_executable(${TEST_TARGET} ${srcs}) target_link_libraries(${TEST_TARGET} updatershared) add_test(NAME ${TEST_TARGET} COMMAND ${TEST_TARGET}) - if (APPLE) + if(APPLE) set_target_properties(${TEST_TARGET} PROPERTIES LINK_FLAGS "-framework Security -framework Cocoa") endif() endmacro() -- cgit v1.2.3