From 414bb6018b1212dfa02e87769d37a7a2837ce6cf Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Tue, 10 Jul 2018 21:06:16 +0200 Subject: [PATCH] CMake: Add Libs.private to Libs if installing static only pkg-config --libs --static raylib and pkg-config --libs raylib should give the same result if there is no shared raylib installed. --- raylib.pc.in | 2 +- src/CMakeLists.txt | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/raylib.pc.in b/raylib.pc.in index f72b3dce..c6d54389 100644 --- a/raylib.pc.in +++ b/raylib.pc.in @@ -7,7 +7,7 @@ Name: raylib Description: Simple and easy-to-use library to learn videogames programming URL: http://github.com/raysan5/raylib Version: @PROJECT_VERSION@ -Libs: -L${libdir} -lraylib +Libs: -L${libdir} -lraylib @PKG_CONFIG_LIBS_EXTRA@ Libs.private: @PKG_CONFIG_LIBS_PRIVATE@ Requires.private: @GLFW_PKG_DEPS@ Cflags: -I${includedir} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 333bcf1d..05e3c0d2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -110,6 +110,8 @@ if(${SHARED}) PUBLIC ${GRAPHICS} ) + set(PKG_CONFIG_LIBS_EXTRA "") + set_property(TARGET ${RAYLIB}_shared PROPERTY POSITION_INDEPENDENT_CODE ON) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}") set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) @@ -155,6 +157,11 @@ if(${STATIC}) add_library(${RAYLIB} STATIC ${sources}) + target_compile_definitions(${RAYLIB} + PUBLIC ${PLATFORM} + PUBLIC ${GRAPHICS} + ) + set(PKG_CONFIG_LIBS_PRIVATE ${__PKG_CONFIG_LIBS_PRIVATE} ${GLFW_PKG_LIBS}) string (REPLACE ";" " " PKG_CONFIG_LIBS_PRIVATE "${PKG_CONFIG_LIBS_PRIVATE}") if (${PLATFORM} MATCHES "PLATFORM_DESKTOP") @@ -173,6 +180,9 @@ if(${STATIC}) add_test("pkg-config--static" ${PROJECT_SOURCE_DIR}/../cmake/test-pkgconfig.sh --static) endif(${STATIC}) +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") @@ -183,12 +193,6 @@ file(COPY "physac.h" DESTINATION ".") file(COPY "raymath.h" DESTINATION ".") file(COPY "audio.h" DESTINATION ".") -target_compile_definitions(${RAYLIB} - PUBLIC ${PLATFORM} - PUBLIC ${GRAPHICS} -) - - # Print the flags for the user message(STATUS "Compiling with the flags:") message(STATUS " PLATFORM=" ${PLATFORM})