Use the same style of CMake files everywhere
This commit is contained in:
@ -6,18 +6,18 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
||||
|
||||
include_directories(depends)
|
||||
|
||||
if (WIN32)
|
||||
include_directories(depends/win32cpp)
|
||||
if(WIN32)
|
||||
include_directories(depends/win32cpp)
|
||||
|
||||
# static all the things. The updater must have no dependencies, or it will fail.
|
||||
if (MINGW)
|
||||
if(MINGW)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -static")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++ -static")
|
||||
#set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static-libgcc -s")
|
||||
#set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -static-libgcc -static-libstdc++ -s")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
if(MSVC)
|
||||
# - Link the updater binary statically with the Visual C++ runtime
|
||||
# so that the executable can function standalone.
|
||||
# - Enable PDB generation for release builds
|
||||
@ -27,14 +27,14 @@ if (WIN32)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "/MT /Zi /O2 /Ob2 /D NDEBUG")
|
||||
set(CMAKE_C_FLAGS_RELEASE "/MT /Zi /O2 /Ob2 /D NDEBUG")
|
||||
remove_definitions(-DUNICODE -D_UNICODE)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
# optimize for reduced code size
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-Os")
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
if(APPLE)
|
||||
# Build the updater as a dual 32/64bit binary. If only one architecture
|
||||
# is required, removing the other architecture will reduce the size
|
||||
# of the updater binary
|
||||
|
@ -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})
|
||||
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)
|
||||
# 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()
|
||||
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()
|
||||
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user