robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
9e80f63c30
master
1set ( DEPS_INSTALL_DIR " ${ CMAKE_BINARY_DIR } /usr" ) 2set ( DEPS_BIN_DIR " ${ DEPS_INSTALL_DIR } /bin" ) 3set ( DEPS_LIB_DIR " ${ DEPS_INSTALL_DIR } /lib" ) 4 5set ( DEPS_BUILD_DIR " ${ CMAKE_BINARY_DIR } /build" ) 6set ( DEPS_DOWNLOAD_DIR " ${ DEPS_BUILD_DIR } /downloads" ) 7 8set ( DEPS_CMAKE_ARGS 9-D CMAKE_C_COMPILER= ${ CMAKE_C_COMPILER } 10-D CMAKE_C_STANDARD=99 11-D CMAKE_GENERATOR= ${ CMAKE_GENERATOR } 12-D CMAKE_GENERATOR_PLATFORM= ${ CMAKE_GENERATOR_PLATFORM } 13-D BUILD_SHARED_LIBS=OFF 14-D CMAKE_POSITION_INDEPENDENT_CODE=ON 15-D CMAKE_INSTALL_PREFIX= ${ DEPS_INSTALL_DIR }) 16if ( APPLE) 17list ( APPEND DEPS_CMAKE_ARGS -D CMAKE_FIND_FRAMEWORK= ${ CMAKE_FIND_FRAMEWORK }) 18endif () 19 20find_program ( CACHE_PRG NAMES ccache sccache ) 21mark_as_advanced ( CACHE_PRG ) 22if ( CACHE_PRG) 23set ( CMAKE_C_COMPILER_LAUNCHER ${ CMAKE_COMMAND } -E env CCACHE_SLOPPINESS=pch_defines,time_macros ${ CACHE_PRG }) 24list ( APPEND DEPS_CMAKE_CACHE_ARGS -DCMAKE_C_COMPILER_LAUNCHER:STRING= ${ CMAKE_C_COMPILER_LAUNCHER }) 25endif () 26 27# MAKE_PRG 28if ( UNIX) 29find_program ( MAKE_PRG NAMES gmake make ) 30mark_as_advanced ( MAKE_PRG ) 31if ( NOT MAKE_PRG) 32message ( FATAL_ERROR "GNU Make is required to build the dependencies." ) 33else () 34message ( STATUS "Found GNU Make at ${ MAKE_PRG } " ) 35endif () 36endif () 37# When using make, use the $(MAKE) variable to avoid warning about the job 38# server. 39if ( CMAKE_GENERATORMATCHES "Makefiles" ) 40set ( MAKE_PRG " $ (MAKE)" ) 41endif () 42if ( MINGWAND CMAKE_GENERATORMATCHES "Ninja" ) 43find_program ( MAKE_PRG NAMES mingw32-make ) 44if ( NOT MAKE_PRG) 45message ( FATAL_ERROR "GNU Make for mingw32 is required to build the dependencies." ) 46else () 47message ( STATUS "Found GNU Make for mingw32: ${ MAKE_PRG } " ) 48endif () 49endif () 50 51# DEPS_C_COMPILER 52set ( DEPS_C_COMPILER " ${ CMAKE_C_COMPILER } " ) 53if ( CMAKE_OSX_SYSROOT) 54set ( DEPS_C_COMPILER " ${ DEPS_C_COMPILER } -isysroot ${ CMAKE_OSX_SYSROOT } " ) 55endif () 56 57get_filename_component ( rootdir ${ PROJECT_SOURCE_DIR } NAME ) 58if (${ rootdir } MATCHES "cmake.deps" ) 59set ( depsfile ${ PROJECT_SOURCE_DIR } /deps.txt ) 60else () 61set ( depsfile ${ PROJECT_SOURCE_DIR } /cmake.deps/deps.txt ) 62endif () 63 64set_directory_properties ( PROPERTIES 65EP_PREFIX " ${ DEPS_BUILD_DIR } " 66CMAKE_CONFIGURE_DEPENDS ${ depsfile }) 67 68file ( READ ${ depsfile } DEPENDENCIES ) 69STRING ( REGEX REPLACE "\n" ";" DEPENDENCIES " ${ DEPENDENCIES } " ) 70# Process deps.txt: 71foreach ( dep${ DEPENDENCIES }) 72STRING ( REGEX REPLACE " " ";" dep " ${ dep } " ) 73list ( GET dep 0 name ) 74if (${ name } MATCHES "^#" ) # Skip comment lines. 75continue () 76endif () 77list ( GET dep 1 value ) 78if ( NOT ${ name }) 79# _URL variables must NOT be set when USE_EXISTING_SRC_DIR is set, 80# otherwise ExternalProject will try to re-download the sources. 81if ( NOT USE_EXISTING_SRC_DIR) 82set ( $ { name } ${ value }) 83endif () 84endif () 85endforeach () 86 87function ( get_externalproject_options name DEPS_IGNORE_SHA ) 88string ( TOUPPER ${ name } name_allcaps ) 89set ( url ${ $ { name_allcaps } _URL }) 90 91set ( EXTERNALPROJECT_OPTIONS 92DOWNLOAD_NO_PROGRESS TRUE 93URL ${ $ { name_allcaps } _URL } 94CMAKE_CACHE_ARGS ${ DEPS_CMAKE_CACHE_ARGS }) 95 96if ( NOT ${ DEPS_IGNORE_SHA }) 97list ( APPEND EXTERNALPROJECT_OPTIONS URL_HASH SHA256= ${ $ { name_allcaps } _SHA256 }) 98endif () 99 100set ( EXTERNALPROJECT_OPTIONS ${ EXTERNALPROJECT_OPTIONS } PARENT_SCOPE ) 101endfunction ()