cmake_modules/paths.cmake
author koda
Fri, 11 Oct 2013 17:43:13 +0200
branchwebgl
changeset 9521 8054d9d775fd
parent 9279 69161099d6d9
parent 9339 14f5f3a1e2f7
child 9950 2759212a27de
permissions -rw-r--r--
merge with latest defaul, fixing compiling with fpc, parsing and rendering with pas2c, some minor problems with compiling with clang
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9190
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
     1
#where to build libs and bins
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
     2
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
     3
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
9224
bce8cf41d666 merge cmake_pascal branch in default
koda
parents: 9220
diff changeset
     4
#these variables are for non-makefile generators
bce8cf41d666 merge cmake_pascal branch in default
koda
parents: 9220
diff changeset
     5
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
bce8cf41d666 merge cmake_pascal branch in default
koda
parents: 9220
diff changeset
     6
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${EXECUTABLE_OUTPUT_PATH})
bce8cf41d666 merge cmake_pascal branch in default
koda
parents: 9220
diff changeset
     7
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${EXECUTABLE_OUTPUT_PATH})
bce8cf41d666 merge cmake_pascal branch in default
koda
parents: 9220
diff changeset
     8
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH})
bce8cf41d666 merge cmake_pascal branch in default
koda
parents: 9220
diff changeset
     9
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${LIBRARY_OUTPUT_PATH})
bce8cf41d666 merge cmake_pascal branch in default
koda
parents: 9220
diff changeset
    10
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${LIBRARY_OUTPUT_PATH})
bce8cf41d666 merge cmake_pascal branch in default
koda
parents: 9220
diff changeset
    11
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH})
bce8cf41d666 merge cmake_pascal branch in default
koda
parents: 9220
diff changeset
    12
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${LIBRARY_OUTPUT_PATH})
bce8cf41d666 merge cmake_pascal branch in default
koda
parents: 9220
diff changeset
    13
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${LIBRARY_OUTPUT_PATH})
9190
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    14
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    15
#resource paths
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    16
if(UNIX AND NOT APPLE)
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    17
    set(target_binary_install_dir "bin")
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    18
    set(target_library_install_dir "lib")
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    19
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    20
    string(SUBSTRING "${DATA_INSTALL_DIR}" 0 1 sharepath_start)
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    21
    if (NOT (${sharepath_start} MATCHES "/"))
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    22
        set(HEDGEWARS_DATADIR "${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}/")
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    23
    else()
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    24
        set(HEDGEWARS_DATADIR "${DATA_INSTALL_DIR}/")
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    25
    endif()
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    26
    set(HEDGEWARS_FULL_DATADIR "${HEDGEWARS_DATADIR}")
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    27
else()
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    28
    set(target_binary_install_dir "./")
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    29
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    30
    if(APPLE)
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    31
        set(target_library_install_dir "../Frameworks/")
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    32
        set(CMAKE_INSTALL_PREFIX "Hedgewars.app/Contents/MacOS/")
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    33
        set(HEDGEWARS_DATADIR "../Resources/")
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    34
        set(HEDGEWARS_FULL_DATADIR "/Applications/${CMAKE_INSTALL_PREFIX}/${HEDGEWARS_DATADIR}")
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    35
    elseif(WIN32)
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    36
        set(target_library_install_dir "./")
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    37
        set(HEDGEWARS_DATADIR "./")
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    38
        set(HEDGEWARS_FULL_DATADIR "${CMAKE_INSTALL_PREFIX}/")
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    39
        link_directories("${EXECUTABLE_OUTPUT_PATH}" "${CMAKE_SOURCE_DIR}/misc/winutils/bin")
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    40
    endif()
4fc0e95e7b64 move paths setup in separate cmake module
koda
parents:
diff changeset
    41
endif()
9198
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    42
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    43
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    44
#RPATH SETTINGS
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    45
#necessary for dynamic libraries on UNIX, ignored elsewhere
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    46
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    47
#use, i.e. don't skip the full RPATH for the build tree
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    48
set(CMAKE_SKIP_BUILD_RPATH FALSE)
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    49
set(CMAKE_SKIP_INSTALL_RPATH FALSE)
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    50
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    51
#it's safe to use our RPATH because it is relative
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    52
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    53
9339
14f5f3a1e2f7 some work on cmake_pascal files to better support flags we use, make engine compile as library again
koda
parents: 9313
diff changeset
    54
#add the automatically determined parts of the RPATH
14f5f3a1e2f7 some work on cmake_pascal files to better support flags we use, make engine compile as library again
koda
parents: 9313
diff changeset
    55
#which point to directories outside the build tree to the install RPATH
14f5f3a1e2f7 some work on cmake_pascal files to better support flags we use, make engine compile as library again
koda
parents: 9313
diff changeset
    56
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
14f5f3a1e2f7 some work on cmake_pascal files to better support flags we use, make engine compile as library again
koda
parents: 9313
diff changeset
    57
9198
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    58
#paths where to find libraries (final slash not optional):
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    59
# - the first is relative to the executable
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    60
# - the second is the same directory of the executable (so it runs in bin/)
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    61
# - the third one is the full path of the system dir
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    62
#source http://www.cmake.org/pipermail/cmake/2008-January/019290.html
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    63
set(CMAKE_INSTALL_RPATH "$ORIGIN/../${target_library_install_dir}/:$ORIGIN/:${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}/")
9279
69161099d6d9 ok you need to escape rpath for pscal scripts after all... (reverts r571e55b32da5)
koda
parents: 9276
diff changeset
    64
#\\\\ is just \\ which escapes '\' in the final script; same for $$ which escapes '$' in cmake
69161099d6d9 ok you need to escape rpath for pscal scripts after all... (reverts r571e55b32da5)
koda
parents: 9276
diff changeset
    65
set(CMAKE_INSTALL_RPATH_ESCAPED "\\\\$$ORIGIN/../${target_library_install_dir}/:\\\\$$ORIGIN/:${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}/")
9198
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    66
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    67
if(UNIX AND NOT APPLE)
9276
91bd3f54fac1 tcc compatibility
koda
parents: 9232
diff changeset
    68
    if(CMAKE_COMPILER_IS_GNUCC)
91bd3f54fac1 tcc compatibility
koda
parents: 9232
diff changeset
    69
       #make sure $ORIGIN is respected
91bd3f54fac1 tcc compatibility
koda
parents: 9232
diff changeset
    70
        add_linker_flag("-zorigin")
91bd3f54fac1 tcc compatibility
koda
parents: 9232
diff changeset
    71
    endif()
9232
571e55b32da5 there is no need of escaping after all...
koda
parents: 9231
diff changeset
    72
    #apply RPATH settings to pascal executables
9279
69161099d6d9 ok you need to escape rpath for pscal scripts after all... (reverts r571e55b32da5)
koda
parents: 9276
diff changeset
    73
    add_flag_append(CMAKE_Pascal_FLAGS "-k-rpath -k'${CMAKE_INSTALL_RPATH_ESCAPED}'")
9232
571e55b32da5 there is no need of escaping after all...
koda
parents: 9231
diff changeset
    74
    #until we link with external things there is no need to set rpath on haskell
571e55b32da5 there is no need of escaping after all...
koda
parents: 9231
diff changeset
    75
    #list(APPEND haskell_flags "-optl" "-Wl,-rpath,'${CMAKE_INSTALL_RPATH_ESCAPED}'")
9198
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    76
endif()
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    77
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    78
#add the automatically determined parts of the RPATH
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    79
#which point to directories outside the build tree to the install RPATH
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    80
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    81
48b92ff6238f setup RPATH, bump cmake
koda
parents: 9190
diff changeset
    82
9200
37c37026f7ec love cmake when it works
koda
parents: 9198
diff changeset
    83
#install_name_tool magic for OS X
37c37026f7ec love cmake when it works
koda
parents: 9198
diff changeset
    84
set(CMAKE_INSTALL_NAME_DIR "@executable_path/../Frameworks")
37c37026f7ec love cmake when it works
koda
parents: 9198
diff changeset
    85