From 78487f7521a48460dda9560569add9893a4862cc Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sun, 29 Jul 2018 21:25:42 +0200 Subject: [PATCH] CMake: Make the raylib project as a whole embeddable So user code can use add_subdirectory to build it (similar to what we do with GLFW or what the projects/CMake/CMakeLists.txt can do). --- projects/CMake/CMakeLists.txt | 4 ++-- src/CMakeLists.txt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt index 68c976e5..cf1d65a6 100644 --- a/projects/CMake/CMakeLists.txt +++ b/projects/CMake/CMakeLists.txt @@ -18,8 +18,8 @@ if (NOT raylib_FOUND) # If there's none, fetch and build raylib set(FETCHCONTENT_QUIET NO) FetchContent_Populate(raylib) - set(BUILD_EXAMPLES OFF) # don't build the supplied examples - set(BUILD_GAMES OFF) # or games + set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples + set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # or games # build raylib add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2e561fc5..70cb5527 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -179,7 +179,7 @@ if(STATIC) ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) -set_target_properties(raylib_static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}/release") +set_target_properties(raylib_static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}") add_test("pkg-config--static" ${PROJECT_SOURCE_DIR}/../cmake/test-pkgconfig.sh --static) endif(STATIC) @@ -229,7 +229,7 @@ if(SHARED) PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) endif() - set_target_properties(raylib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_BINARY_DIR}/release") + set_target_properties(raylib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}") add_test("pkg-config" ${PROJECT_SOURCE_DIR}/../cmake/test-pkgconfig.sh) else(SHARED) @@ -240,9 +240,9 @@ if (NOT DEFINED PKG_CONFIG_LIBS_EXTRA) set(PKG_CONFIG_LIBS_EXTRA "${PKG_CONFIG_LIBS_PRIVATE}") endif() configure_file(../raylib.pc.in raylib.pc @ONLY) -install(FILES ${CMAKE_BINARY_DIR}/release/raylib.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/raylib.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") configure_file(../cmake/raylib-config-version.cmake raylib-config-version.cmake @ONLY) -install(FILES ${CMAKE_BINARY_DIR}/release/raylib-config-version.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib") +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/raylib-config-version.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib") install(FILES ${PROJECT_SOURCE_DIR}/../cmake/raylib-config.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/raylib") # populates raylib_{FOUND, INCLUDE_DIRS, LIBRARIES, LDFLAGS, DEFINITIONS}