tools/CMakeLists.txt
author unc0rr
Fri, 08 Nov 2013 17:53:02 +0400
branchsdl2transition
changeset 9694 e8d0fe885169
parent 9679 dfaa39674e1e
child 9703 966d180184b4
permissions -rw-r--r--
- Keyboard bindings seem to work fully - Catch mouse wheel event (bindings don't work for unknown reason)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2593
dd995a9c8871 add an uninstall target (to be tested)
koda
parents: 2550
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
5053
a767954cfa03 this should help people hacking the cmake files
koda
parents: 4775
diff changeset
     9
if (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
    10
    find_package(Qt4 REQUIRED QUIET)
9679
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    11
    if(${USESDL12})
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    12
        find_package(SDL REQUIRED)
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    13
        find_package(SDL_image REQUIRED)
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    14
        find_package(SDL_net REQUIRED)
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    15
        find_package(SDL_ttf REQUIRED)
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    16
        find_package(SDL_mixer REQUIRED)
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    17
        find_package(OggVorbis REQUIRED)
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    18
    else(${USESDL12})
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    19
        find_package(SDL2 REQUIRED)
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    20
        find_package(SDL2_image REQUIRED)
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    21
        find_package(SDL2_net REQUIRED)
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    22
        find_package(SDL2_ttf REQUIRED)
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    23
        find_package(SDL2_mixer REQUIRED)
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    24
    endif(${USESDL12})
dfaa39674e1e some improvements for sdl2 building (not complete nor clean)
koda
parents: 9347
diff changeset
    25
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
    26
    if(NOT NOAUTOUPDATE)
8659
e49056d3aba1 fail if sparkle not found consciously
koda
parents: 8322
diff changeset
    27
        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
    28
        #needed because the 'if' clause in the script prints silly policy warnings
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
    29
        if(${SPARKLE_FOUND})
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
    30
            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
    31
        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
    32
            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
    33
        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
    34
    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
    35
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
    36
    #use the associated tool from the libraries we've selected
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
    37
    string(REGEX REPLACE "(.*)/include.*" "\\1" qt_base_dir "${QT_INCLUDE_DIR}")
4335
c279aeb615df improve mac bundle creation
koda
parents: 2641
diff changeset
    38
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
    39
    #remove the ";-framework Cocoa" from the SDL_LIBRARY variable
8316
89232b2fa1d6 cmake rework, cleanup a lot of redundant sections, separate library and binary install location, unify osx and win handling of the data directory (tested on win, lin and mac)
koda
parents: 7817
diff changeset
    40
    string(REGEX REPLACE "(.*);-.*" "\\1" sdl_library_only "${SDL_LIBRARY}")
5169
e353ca78d28b some comments and simplifications for cmake files
koda
parents: 5096
diff changeset
    41
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
    42
    if(NOT NOPNG)
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
    43
        #get the neme of the library (harmelss if it is static)
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
    44
        string(REGEX REPLACE ".*/(.*)$" "\\1" PNG_LIBNAME "${PNG_LIBRARY}")
9050
e9d54cd577e7 perhaps unneeded, but...
koda
parents: 8660
diff changeset
    45
        string(REGEX REPLACE ".*/(.*)$" "\\1" ZLIB_LIBNAME "${ZLIB_LIBRARY}")
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
    46
    endif()
2219
07f5345ecae7 additional variable (BUNDLE) to make a standalone Mac application
koda
parents:
diff changeset
    47
8317
ec9f94ab2737 remove the CROSSAPPLE option until a better solution is found
koda
parents: 8316
diff changeset
    48
    set(frameworks_dir ${CMAKE_INSTALL_PREFIX}/${target_library_install_dir})
8322
50369fa5053b adjust rpath on osx too for libengine
koda
parents: 8317
diff changeset
    49
    if(${BUILD_ENGINE_LIBRARY})
50369fa5053b adjust rpath on osx too for libengine
koda
parents: 8317
diff changeset
    50
        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
    51
    else()
50369fa5053b adjust rpath on osx too for libengine
koda
parents: 8317
diff changeset
    52
        set(engine_full_path "${CMAKE_INSTALL_PREFIX}/hwengine${CMAKE_EXECUTABLE_SUFFIX}")
50369fa5053b adjust rpath on osx too for libengine
koda
parents: 8317
diff changeset
    53
    endif()
8317
ec9f94ab2737 remove the CROSSAPPLE option until a better solution is found
koda
parents: 8316
diff changeset
    54
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
    55
    #this tool is present in qt 4.5 but only if you compile from sources
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
    56
    #from qt 4.6 is present also in the binary version
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
    57
    find_program(macdeployqt_executable NAMES macdeployqt macdeployqt-mac PATHS ${qt_base_dir}/bin)
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
    58
    if(NOT macdeployqt_executable)
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
    59
        message(FATAL_ERROR "The utility macdeployqt is required to create the bundle (seached: ${qt_base_dir})")
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
    60
    endif()
2219
07f5345ecae7 additional variable (BUNDLE) to make a standalone Mac application
koda
parents:
diff changeset
    61
9345
bb9bf1efd0d2 use the modern install(SCRIPT ...) command instead of legacy POST_BUILD_SCRIPT
koda
parents: 9229
diff changeset
    62
    #create the .app bundle
bb9bf1efd0d2 use the modern install(SCRIPT ...) command instead of legacy POST_BUILD_SCRIPT
koda
parents: 9229
diff changeset
    63
    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
    64
    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
    65
            CODE "message(STATUS \"Your app bundle is ready\")")
2219
07f5345ecae7 additional variable (BUNDLE) to make a standalone Mac application
koda
parents:
diff changeset
    66
9347
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    67
    #create the .dmg for deployment
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    68
    #first make sure .app exists, then remove any old .dmg with same name, finally run the script
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    69
    add_custom_target(dmg COMMAND if [ ! -a Hedgewars.app ]; then make install\; fi;
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    70
                          COMMAND rm -f ${CMAKE_BINARY_DIR}/Hedgewars-${HEDGEWARS_VERSION}.dmg
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    71
                          COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/create-dmg.sh
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    72
                                  --volname "Hedgewars ${HEDGEWARS_VERSION}"
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    73
                                # --volicon icon.icns
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    74
                                  --window-size 600 470
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    75
                                  --icon-size 96
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    76
                                  --icon "Hedgewars" 190 190
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    77
                                  --app-drop-link 410 190
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    78
                                  --background "${CMAKE_CURRENT_SOURCE_DIR}/../misc/dmgBackground.png"
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    79
                                  ${CMAKE_BINARY_DIR}/Hedgewars-${HEDGEWARS_VERSION}.dmg
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    80
                                  ${CMAKE_BINARY_DIR}/Hedgewars.app
5b582d49358c automate dmg creation (woo)
koda
parents: 9345
diff changeset
    81
                          WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
5169
e353ca78d28b some comments and simplifications for cmake files
koda
parents: 5096
diff changeset
    82
endif()
2547
koda
parents: 2546
diff changeset
    83