tools/CMakeLists.txt
author nemo
Fri, 21 Jun 2019 22:36:50 -0400
changeset 15196 0e8bb82af355
parent 14928 d6e21765912e
child 15318 7e3bd4030aa5
permissions -rw-r--r--
48 used to be the limit
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9963
9e75dbffec81 drop extra spaces from a few CMakeLists.txt files
koda
parents: 9961
diff changeset
     1
if(NOT APPLE)
7817
6cc558a69b58 countless small optimisation for cmake, output messages are now coherent (mostly) and the options get fully respected (eg. skipping library search if not activated)
koda
parents: 7112
diff changeset
     2
    configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
6cc558a69b58 countless small optimisation for cmake, output messages are now coherent (mostly) and the options get fully respected (eg. skipping library search if not activated)
koda
parents: 7112
diff changeset
     3
                   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
6cc558a69b58 countless small optimisation for cmake, output messages are now coherent (mostly) and the options get fully respected (eg. skipping library search if not activated)
koda
parents: 7112
diff changeset
     4
                    IMMEDIATE @ONLY)
2593
dd995a9c8871 add an uninstall target (to be tested)
koda
parents: 2550
diff changeset
     5
7817
6cc558a69b58 countless small optimisation for cmake, output messages are now coherent (mostly) and the options get fully respected (eg. skipping library search if not activated)
koda
parents: 7112
diff changeset
     6
    add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
2593
dd995a9c8871 add an uninstall target (to be tested)
koda
parents: 2550
diff changeset
     7
endif()
dd995a9c8871 add an uninstall target (to be tested)
koda
parents: 2550
diff changeset
     8
10976
56f07b52213a Allow skipping the bundle step after install on OSX
koda
parents: 10975
diff changeset
     9
if(APPLE AND NOT SKIPBUNDLE)
13343
0b12b0d0d12c Fix outdated Qt CMake dependency for OS X
Wuzzy <Wuzzy2@mail.ru>
parents: 12391
diff changeset
    10
    find_package(Qt5 REQUIRED QUIET COMPONENTS Core Widgets Gui Network)
11342
ed5a6478e710 merge default
sheepluva
parents: 9703 11276
diff changeset
    11
    find_package(SDL2 REQUIRED)
12391
e4f8bf43224d fix build. sorry 'bout that.
sheepluva
parents: 11615
diff changeset
    12
    find_package(SDL2_image 2 REQUIRED)
e4f8bf43224d fix build. sorry 'bout that.
sheepluva
parents: 11615
diff changeset
    13
    find_package(SDL2_net 2 REQUIRED)
e4f8bf43224d fix build. sorry 'bout that.
sheepluva
parents: 11615
diff changeset
    14
    find_package(SDL2_ttf 2 REQUIRED)
e4f8bf43224d fix build. sorry 'bout that.
sheepluva
parents: 11615
diff changeset
    15
    find_package(SDL2_mixer 2 REQUIRED)
11615
523b153f7f22 Add FindOggVorbis to make sure all paths are set
koda
parents: 11614
diff changeset
    16
    find_package(OggVorbis REQUIRED)
10975
47c3a00f8037 Make sure that the png library name is always defined
koda
parents: 10974
diff changeset
    17
    find_package(PNG REQUIRED)
9679
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    18
7817
6cc558a69b58 countless small optimisation for cmake, output messages are now coherent (mostly) and the options get fully respected (eg. skipping library search if not activated)
koda
parents: 7112
diff changeset
    19
    if(NOT NOAUTOUPDATE)
8659
e49056d3aba1 fail if sparkle not found consciously
koda
parents: 8322
diff changeset
    20
        find_package(Sparkle) #needed for SPARKLE_FOUND variable
7817
6cc558a69b58 countless small optimisation for cmake, output messages are now coherent (mostly) and the options get fully respected (eg. skipping library search if not activated)
koda
parents: 7112
diff changeset
    21
        #needed because the 'if' clause in the script prints silly policy warnings
9961
c18c66d621e5 consistent cmake checks
koda
parents: 9347
diff changeset
    22
        if(SPARKLE_FOUND)
7817
6cc558a69b58 countless small optimisation for cmake, output messages are now coherent (mostly) and the options get fully respected (eg. skipping library search if not activated)
koda
parents: 7112
diff changeset
    23
            set(SPARKLE_FOUND 1)
6cc558a69b58 countless small optimisation for cmake, output messages are now coherent (mostly) and the options get fully respected (eg. skipping library search if not activated)
koda
parents: 7112
diff changeset
    24
        else()
6cc558a69b58 countless small optimisation for cmake, output messages are now coherent (mostly) and the options get fully respected (eg. skipping library search if not activated)
koda
parents: 7112
diff changeset
    25
            set(SPARKLE_FOUND 0)
6cc558a69b58 countless small optimisation for cmake, output messages are now coherent (mostly) and the options get fully respected (eg. skipping library search if not activated)
koda
parents: 7112
diff changeset
    26
        endif()
6cc558a69b58 countless small optimisation for cmake, output messages are now coherent (mostly) and the options get fully respected (eg. skipping library search if not activated)
koda
parents: 7112
diff changeset
    27
    endif()
6cc558a69b58 countless small optimisation for cmake, output messages are now coherent (mostly) and the options get fully respected (eg. skipping library search if not activated)
koda
parents: 7112
diff changeset
    28
14928
d6e21765912e Fix macdeployqt finding with Qt5 on macos
Anton Malmygin <antonc27@mail.ru>
parents: 13343
diff changeset
    29
    get_target_property(qmake_executable Qt5::qmake IMPORTED_LOCATION)
d6e21765912e Fix macdeployqt finding with Qt5 on macos
Anton Malmygin <antonc27@mail.ru>
parents: 13343
diff changeset
    30
    get_filename_component(qt_bin_dir "${qmake_executable}" DIRECTORY)
4335
c279aeb615df improve mac bundle creation
koda
parents: 2641
diff changeset
    31
11614
b77870abb3c4 Update osx bundle creation with SDL2 library names
koda
parents: 11342
diff changeset
    32
    #remove the ";-framework Cocoa" from the SDL2_LIBRARY variable
b77870abb3c4 Update osx bundle creation with SDL2 library names
koda
parents: 11342
diff changeset
    33
    string(REGEX REPLACE "(.*);-.*" "\\1" sdl_library_only "${SDL2_LIBRARY}")
b77870abb3c4 Update osx bundle creation with SDL2 library names
koda
parents: 11342
diff changeset
    34
    #remove the "libSDLmain.a" from the SDL2_LIBRARY variable
10974
0f9fc5923be4 Fix libsdl bundling on OSX when library rather than framework is used
koda
parents: 10382
diff changeset
    35
    string(REGEX REPLACE ".*;(.*)" "\\1" sdl_library_only "${sdl_library_only}")
5169
e353ca78d28b some comments and simplifications for cmake files
koda
parents: 5096
diff changeset
    36
10975
47c3a00f8037 Make sure that the png library name is always defined
koda
parents: 10974
diff changeset
    37
    #get the neme of the library (harmelss if it is static)
47c3a00f8037 Make sure that the png library name is always defined
koda
parents: 10974
diff changeset
    38
    string(REGEX REPLACE ".*/(.*)$" "\\1" PNG_LIBNAME "${PNG_LIBRARY}")
47c3a00f8037 Make sure that the png library name is always defined
koda
parents: 10974
diff changeset
    39
    string(REGEX REPLACE ".*/(.*)$" "\\1" ZLIB_LIBNAME "${ZLIB_LIBRARY}")
2219
07f5345ecae7 additional variable (BUNDLE) to make a standalone Mac application
koda
parents:
diff changeset
    40
8317
ec9f94ab2737 remove the CROSSAPPLE option until a better solution is found
koda
parents: 8316
diff changeset
    41
    set(frameworks_dir ${CMAKE_INSTALL_PREFIX}/${target_library_install_dir})
8322
50369fa5053b adjust rpath on osx too for libengine
koda
parents: 8317
diff changeset
    42
    if(${BUILD_ENGINE_LIBRARY})
50369fa5053b adjust rpath on osx too for libengine
koda
parents: 8317
diff changeset
    43
        set(engine_full_path "${frameworks_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}")
50369fa5053b adjust rpath on osx too for libengine
koda
parents: 8317
diff changeset
    44
    else()
50369fa5053b adjust rpath on osx too for libengine
koda
parents: 8317
diff changeset
    45
        set(engine_full_path "${CMAKE_INSTALL_PREFIX}/hwengine${CMAKE_EXECUTABLE_SUFFIX}")
50369fa5053b adjust rpath on osx too for libengine
koda
parents: 8317
diff changeset
    46
    endif()
8317
ec9f94ab2737 remove the CROSSAPPLE option until a better solution is found
koda
parents: 8316
diff changeset
    47
14928
d6e21765912e Fix macdeployqt finding with Qt5 on macos
Anton Malmygin <antonc27@mail.ru>
parents: 13343
diff changeset
    48
    find_program(macdeployqt_executable NAMES macdeployqt PATHS ${qt_bin_dir})
7817
6cc558a69b58 countless small optimisation for cmake, output messages are now coherent (mostly) and the options get fully respected (eg. skipping library search if not activated)
koda
parents: 7112
diff changeset
    49
    if(NOT macdeployqt_executable)
14928
d6e21765912e Fix macdeployqt finding with Qt5 on macos
Anton Malmygin <antonc27@mail.ru>
parents: 13343
diff changeset
    50
        message(FATAL_ERROR "The utility macdeployqt is required to create the bundle (searched: ${qt_bin_dir})")
7817
6cc558a69b58 countless small optimisation for cmake, output messages are now coherent (mostly) and the options get fully respected (eg. skipping library search if not activated)
koda
parents: 7112
diff changeset
    51
    endif()
2219
07f5345ecae7 additional variable (BUNDLE) to make a standalone Mac application
koda
parents:
diff changeset
    52
9345
bb9bf1efd0d2 use the modern install(SCRIPT ...) command instead of legacy POST_BUILD_SCRIPT
koda
parents: 9229
diff changeset
    53
    #create the .app bundle
bb9bf1efd0d2 use the modern install(SCRIPT ...) command instead of legacy POST_BUILD_SCRIPT
koda
parents: 9229
diff changeset
    54
    configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CreateMacBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake)
bb9bf1efd0d2 use the modern install(SCRIPT ...) command instead of legacy POST_BUILD_SCRIPT
koda
parents: 9229
diff changeset
    55
    install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/CreateMacBundle.cmake
bb9bf1efd0d2 use the modern install(SCRIPT ...) command instead of legacy POST_BUILD_SCRIPT
koda
parents: 9229
diff changeset
    56
            CODE "message(STATUS \"Your app bundle is ready\")")
2219
07f5345ecae7 additional variable (BUNDLE) to make a standalone Mac application
koda
parents:
diff changeset
    57
9347
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    58
    #create the .dmg for deployment
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    59
    #first make sure .app exists, then remove any old .dmg with same name, finally run the script
11276
a292efd31bde Always install before making dmg
koda
parents: 10976
diff changeset
    60
    add_custom_target(dmg COMMAND make install
9347
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    61
                          COMMAND rm -f ${CMAKE_BINARY_DIR}/Hedgewars-${HEDGEWARS_VERSION}.dmg
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    62
                          COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/create-dmg.sh
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    63
                                  --volname "Hedgewars ${HEDGEWARS_VERSION}"
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    64
                                # --volicon icon.icns
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    65
                                  --window-size 600 470
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    66
                                  --icon-size 96
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    67
                                  --icon "Hedgewars" 190 190
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    68
                                  --app-drop-link 410 190
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    69
                                  --background "${CMAKE_CURRENT_SOURCE_DIR}/../misc/dmgBackground.png"
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    70
                                  ${CMAKE_BINARY_DIR}/Hedgewars-${HEDGEWARS_VERSION}.dmg
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    71
                                  ${CMAKE_BINARY_DIR}/Hedgewars.app
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    72
                          WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
5169
e353ca78d28b some comments and simplifications for cmake files
koda
parents: 5096
diff changeset
    73
endif()
2547
koda
parents: 2546
diff changeset
    74