From 20ddc6a2bb4cbd39c460d8fa5d1f7175095bba2f Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sun, 20 May 2018 19:47:19 +0200 Subject: Move utils.cmake to separate cmake/ directory --- cmake/utils.cmake | 88 ++++++++++++++++++++++++++++++++++++ examples/CMakeLists.txt | 2 +- games/CMakeLists.txt | 2 +- games/drturtle/CMakeLists.txt | 2 +- games/just_do/CMakeLists.txt | 2 +- games/koala_seasons/CMakeLists.txt | 2 +- games/light_my_ritual/CMakeLists.txt | 2 +- games/skully_escape/CMakeLists.txt | 2 +- games/wave_collector/CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- utils.cmake | 88 ------------------------------------ 11 files changed, 97 insertions(+), 97 deletions(-) create mode 100755 cmake/utils.cmake delete mode 100755 utils.cmake diff --git a/cmake/utils.cmake b/cmake/utils.cmake new file mode 100755 index 00000000..27f74e68 --- /dev/null +++ b/cmake/utils.cmake @@ -0,0 +1,88 @@ +# All sorts of things that we need cross project +cmake_minimum_required(VERSION 2.8.0) + +add_definitions("-DRAYLIB_CMAKE=1") + +# Linking for OS X -framework options +# Will do nothing on other OSes +if(APPLE) + find_library(OPENGL_LIBRARY OpenGL) + find_library(COCOA_LIBRARY Cocoa) + find_library(IOKIT_LIBRARY IOKit) + find_library(COREFOUNDATION_LIBRARY CoreFoundation) + find_library(COREVIDEO_LIBRARY CoreVideo) + + set(LIBS_PRIVATE ${OPENGL_LIBRARY} ${COCOA_LIBRARY} + ${IOKIT_LIBRARY} ${COREFOUNDATION_LIBRARY} ${COREVIDEO_LIBRARY}) +elseif(WIN32) + # no pkg-config --static on Windows yet... +else() + find_library(pthread NAMES pthread) + find_package(OpenGL QUIET) + if ("${OPENGL_LIBRARIES}" STREQUAL "") + set(OPENGL_LIBRARIES "GL") + endif() + + include_directories(${OPENGL_INCLUDE_DIR}) + + if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD") + find_library(OSS_LIBRARY ossaudio) + endif() + + set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY}) + # TODO: maybe read those out of glfw's cmake config? + if(USE_WAYLAND) + set(LIBS_PRIVATE ${LIBS_PRIVATE} wayland-client wayland-cursor wayland-egl) + else() + set(LIBS_PRIVATE ${LIBS_PRIVATE} X11 Xrandr Xinerama Xi Xxf86vm Xcursor) + endif() +endif() + +if(USE_EXTERNAL_GLFW STREQUAL "ON") + find_package(glfw3 3.2.1 REQUIRED) +elseif(USE_EXTERNAL_GLFW STREQUAL "IF_POSSIBLE") + find_package(glfw3 3.2.1 QUIET) +endif() +if (glfw3_FOUND) + set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw) +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL Linux) + set(LINUX TRUE) + set(LIBS_PRIVATE dl ${LIBS_PRIVATE}) +endif() + +foreach(L ${LIBS_PRIVATE}) + get_filename_component(DIR ${L} PATH) + get_filename_component(LIBFILE ${L} NAME_WE) + STRING(REGEX REPLACE "^lib" "" FILE ${LIBFILE}) + + if (${L} MATCHES "[.]framework$") + set(FILE_OPT "-framework ${FILE}") + set(DIR_OPT "-F${DIR}") + else() + set(FILE_OPT "-l${FILE}") + set(DIR_OPT "-L${DIR}") + endif() + + if ("${DIR}" STREQUAL "" OR "${DIR}" STREQUAL "${LASTDIR}") + set (DIR_OPT "") + endif() + + set(LASTDIR ${DIR}) + + set(__PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE} ${DIR_OPT} ${FILE_OPT}) + string (REPLACE ";" " " __PKG_CONFIG_LIBS_PRIVATE "${__PKG_CONFIG_LIBS_PRIVATE}") +endforeach(L) + + + +# Do the linking for executables that are meant to link raylib +function(link_libraries_to_executable executable) + # Link raylib + if (TARGET raylib_shared) + target_link_libraries(${executable} raylib_shared) + else() + target_link_libraries(${executable} raylib ${__PKG_CONFIG_LIBS_PRIVATE}) + endif() +endfunction() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1f05d529..ae882444 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,7 +1,7 @@ # Setup the project and settings project(examples) -include("../utils.cmake") +include("../cmake/utils.cmake") # Make sure raylib has been built # TODO `build` directory should maybe be something else... diff --git a/games/CMakeLists.txt b/games/CMakeLists.txt index 278d1330..35c99139 100644 --- a/games/CMakeLists.txt +++ b/games/CMakeLists.txt @@ -1,7 +1,7 @@ # Setup the project and settings project(games) -include("../utils.cmake") +include("../cmake/utils.cmake") # Make sure raylib has been built # TODO `build` directory should maybe be something else... diff --git a/games/drturtle/CMakeLists.txt b/games/drturtle/CMakeLists.txt index 59813fb3..bdd91970 100644 --- a/games/drturtle/CMakeLists.txt +++ b/games/drturtle/CMakeLists.txt @@ -1,7 +1,7 @@ # Setup the project and settings project(drturtle) -include("../../utils.cmake") +include("../../cmake/utils.cmake") # Make sure raylib has been built diff --git a/games/just_do/CMakeLists.txt b/games/just_do/CMakeLists.txt index 11644008..4c5e1ee4 100644 --- a/games/just_do/CMakeLists.txt +++ b/games/just_do/CMakeLists.txt @@ -1,7 +1,7 @@ # Setup the project and settings project(just_do) -include("../../utils.cmake") +include("../../cmake/utils.cmake") # Make sure raylib has been built diff --git a/games/koala_seasons/CMakeLists.txt b/games/koala_seasons/CMakeLists.txt index 16069a7e..f79ab911 100644 --- a/games/koala_seasons/CMakeLists.txt +++ b/games/koala_seasons/CMakeLists.txt @@ -1,7 +1,7 @@ # Setup the project and settings project(koala_seasons) -include("../../utils.cmake") +include("../../cmake/utils.cmake") # Make sure raylib has been built diff --git a/games/light_my_ritual/CMakeLists.txt b/games/light_my_ritual/CMakeLists.txt index 1e2cafe1..11d2e4f4 100644 --- a/games/light_my_ritual/CMakeLists.txt +++ b/games/light_my_ritual/CMakeLists.txt @@ -1,7 +1,7 @@ # Setup the project and settings project(light_my_ritual) -include("../../utils.cmake") +include("../../cmake/utils.cmake") # Make sure raylib has been built diff --git a/games/skully_escape/CMakeLists.txt b/games/skully_escape/CMakeLists.txt index d14f52d9..337e1db5 100644 --- a/games/skully_escape/CMakeLists.txt +++ b/games/skully_escape/CMakeLists.txt @@ -1,7 +1,7 @@ # Setup the project and settings project(skully_escape) -include("../../utils.cmake") +include("../../cmake/utils.cmake") # Make sure raylib has been built diff --git a/games/wave_collector/CMakeLists.txt b/games/wave_collector/CMakeLists.txt index c16bd426..ca6c37b8 100644 --- a/games/wave_collector/CMakeLists.txt +++ b/games/wave_collector/CMakeLists.txt @@ -1,7 +1,7 @@ # Setup the project and settings project(wave_collector) -include("../../utils.cmake") +include("../../cmake/utils.cmake") # Make sure raylib has been built diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 458b9606..4b32de10 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -39,7 +39,7 @@ if(NOT glfw3_FOUND) list(APPEND raylib_sources $) endif() -include("../utils.cmake") +include("../cmake/utils.cmake") if(USE_AUDIO) file(GLOB stb_vorbis external/stb_vorbis.c) diff --git a/utils.cmake b/utils.cmake deleted file mode 100755 index 27f74e68..00000000 --- a/utils.cmake +++ /dev/null @@ -1,88 +0,0 @@ -# All sorts of things that we need cross project -cmake_minimum_required(VERSION 2.8.0) - -add_definitions("-DRAYLIB_CMAKE=1") - -# Linking for OS X -framework options -# Will do nothing on other OSes -if(APPLE) - find_library(OPENGL_LIBRARY OpenGL) - find_library(COCOA_LIBRARY Cocoa) - find_library(IOKIT_LIBRARY IOKit) - find_library(COREFOUNDATION_LIBRARY CoreFoundation) - find_library(COREVIDEO_LIBRARY CoreVideo) - - set(LIBS_PRIVATE ${OPENGL_LIBRARY} ${COCOA_LIBRARY} - ${IOKIT_LIBRARY} ${COREFOUNDATION_LIBRARY} ${COREVIDEO_LIBRARY}) -elseif(WIN32) - # no pkg-config --static on Windows yet... -else() - find_library(pthread NAMES pthread) - find_package(OpenGL QUIET) - if ("${OPENGL_LIBRARIES}" STREQUAL "") - set(OPENGL_LIBRARIES "GL") - endif() - - include_directories(${OPENGL_INCLUDE_DIR}) - - if ("${CMAKE_SYSTEM_NAME}" MATCHES "(Net|Open)BSD") - find_library(OSS_LIBRARY ossaudio) - endif() - - set(LIBS_PRIVATE m pthread ${OPENGL_LIBRARIES} ${OSS_LIBRARY}) - # TODO: maybe read those out of glfw's cmake config? - if(USE_WAYLAND) - set(LIBS_PRIVATE ${LIBS_PRIVATE} wayland-client wayland-cursor wayland-egl) - else() - set(LIBS_PRIVATE ${LIBS_PRIVATE} X11 Xrandr Xinerama Xi Xxf86vm Xcursor) - endif() -endif() - -if(USE_EXTERNAL_GLFW STREQUAL "ON") - find_package(glfw3 3.2.1 REQUIRED) -elseif(USE_EXTERNAL_GLFW STREQUAL "IF_POSSIBLE") - find_package(glfw3 3.2.1 QUIET) -endif() -if (glfw3_FOUND) - set(LIBS_PRIVATE ${LIBS_PRIVATE} glfw) -endif() - -if(CMAKE_SYSTEM_NAME STREQUAL Linux) - set(LINUX TRUE) - set(LIBS_PRIVATE dl ${LIBS_PRIVATE}) -endif() - -foreach(L ${LIBS_PRIVATE}) - get_filename_component(DIR ${L} PATH) - get_filename_component(LIBFILE ${L} NAME_WE) - STRING(REGEX REPLACE "^lib" "" FILE ${LIBFILE}) - - if (${L} MATCHES "[.]framework$") - set(FILE_OPT "-framework ${FILE}") - set(DIR_OPT "-F${DIR}") - else() - set(FILE_OPT "-l${FILE}") - set(DIR_OPT "-L${DIR}") - endif() - - if ("${DIR}" STREQUAL "" OR "${DIR}" STREQUAL "${LASTDIR}") - set (DIR_OPT "") - endif() - - set(LASTDIR ${DIR}) - - set(__PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE} ${DIR_OPT} ${FILE_OPT}) - string (REPLACE ";" " " __PKG_CONFIG_LIBS_PRIVATE "${__PKG_CONFIG_LIBS_PRIVATE}") -endforeach(L) - - - -# Do the linking for executables that are meant to link raylib -function(link_libraries_to_executable executable) - # Link raylib - if (TARGET raylib_shared) - target_link_libraries(${executable} raylib_shared) - else() - target_link_libraries(${executable} raylib ${__PKG_CONFIG_LIBS_PRIVATE}) - endif() -endfunction() -- cgit v1.2.3