From ce7ced5488f41a67bc56727220de4c826981e3ff Mon Sep 17 00:00:00 2001 From: Ceylo Date: Sat, 13 Jan 2018 00:19:56 +0100 Subject: [PATCH] Replace INSTALL_RESOURCES_DIR option of sfml_add_example() command with RESOURCES_DIR --- cmake/Macros.cmake | 18 ++++++++++-------- examples/opengl/CMakeLists.txt | 2 +- examples/pong/CMakeLists.txt | 2 +- examples/shader/CMakeLists.txt | 2 +- examples/sound/CMakeLists.txt | 2 +- examples/win32/CMakeLists.txt | 2 +- 6 files changed, 15 insertions(+), 13 deletions(-) diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index ae53369ad..99a996039 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -153,11 +153,11 @@ endmacro() # SOURCES ftp.cpp ... # BUNDLE_RESOURCES MainMenu.nib ... # Files to be added in target but not installed next to the executable # DEPENDS sfml-network sfml-system -# [INSTALL_RESOURCES_DIR]) # In addition to the sources, also install the "resources" directory +# RESOURCES_DIR resources) # A directory to install next to the executable and sources macro(sfml_add_example target) # parse the arguments - cmake_parse_arguments(THIS "GUI_APP;INSTALL_RESOURCES_DIR" "" "SOURCES;BUNDLE_RESOURCES;DEPENDS" ${ARGN}) + cmake_parse_arguments(THIS "GUI_APP" "RESOURCES_DIR" "SOURCES;BUNDLE_RESOURCES;DEPENDS" ${ARGN}) # set a source group for the source files source_group("" FILES ${THIS_SOURCES}) @@ -206,14 +206,16 @@ macro(sfml_add_example target) DESTINATION ${INSTALL_MISC_DIR}/examples/${target} COMPONENT examples) - if (THIS_INSTALL_RESOURCES_DIR) + if (THIS_RESOURCES_DIR) # install the example's resources as well - set(EXAMPLE_RESOURCES "${CMAKE_SOURCE_DIR}/examples/${target}/resources") - if(EXISTS ${EXAMPLE_RESOURCES}) - install(DIRECTORY ${EXAMPLE_RESOURCES} - DESTINATION ${INSTALL_MISC_DIR}/examples/${target} - COMPONENT examples) + get_filename_component(THIS_RESOURCES_DIR "${THIS_RESOURCES_DIR}" ABSOLUTE) + + if(NOT EXISTS "${THIS_RESOURCES_DIR}") + message(FATAL_ERROR "Given resources directory to install does not exist: ${THIS_RESOURCES_DIR}") endif() + install(DIRECTORY ${THIS_RESOURCES_DIR} + DESTINATION ${INSTALL_MISC_DIR}/examples/${target} + COMPONENT examples) endif() endmacro() diff --git a/examples/opengl/CMakeLists.txt b/examples/opengl/CMakeLists.txt index 33ee64dd3..14fad5de7 100644 --- a/examples/opengl/CMakeLists.txt +++ b/examples/opengl/CMakeLists.txt @@ -13,4 +13,4 @@ set(ADDITIONAL_LIBRARIES ${OPENGL_LIBRARIES}) sfml_add_example(opengl GUI_APP SOURCES ${SRC} DEPENDS sfml-graphics sfml-window sfml-system ${ADDITIONAL_LIBRARIES} - INSTALL_RESOURCES_DIR) + RESOURCES_DIR resources) diff --git a/examples/pong/CMakeLists.txt b/examples/pong/CMakeLists.txt index 4bec54744..31334fa14 100644 --- a/examples/pong/CMakeLists.txt +++ b/examples/pong/CMakeLists.txt @@ -8,4 +8,4 @@ set(SRC ${SRCROOT}/Pong.cpp) sfml_add_example(pong GUI_APP SOURCES ${SRC} DEPENDS sfml-audio sfml-graphics sfml-window sfml-system - INSTALL_RESOURCES_DIR) + RESOURCES_DIR resources) diff --git a/examples/shader/CMakeLists.txt b/examples/shader/CMakeLists.txt index 0b85f4a52..a90b2c951 100644 --- a/examples/shader/CMakeLists.txt +++ b/examples/shader/CMakeLists.txt @@ -10,4 +10,4 @@ set(SRC sfml_add_example(shader GUI_APP SOURCES ${SRC} DEPENDS sfml-graphics sfml-window sfml-system - INSTALL_RESOURCES_DIR) + RESOURCES_DIR resources) diff --git a/examples/sound/CMakeLists.txt b/examples/sound/CMakeLists.txt index b266356ad..99c11ca17 100644 --- a/examples/sound/CMakeLists.txt +++ b/examples/sound/CMakeLists.txt @@ -8,4 +8,4 @@ set(SRC ${SRCROOT}/Sound.cpp) sfml_add_example(sound SOURCES ${SRC} DEPENDS sfml-audio sfml-system - INSTALL_RESOURCES_DIR) + RESOURCES_DIR resources) diff --git a/examples/win32/CMakeLists.txt b/examples/win32/CMakeLists.txt index 3155b28aa..1f970600b 100644 --- a/examples/win32/CMakeLists.txt +++ b/examples/win32/CMakeLists.txt @@ -8,4 +8,4 @@ set(SRC ${SRCROOT}/Win32.cpp) sfml_add_example(win32 GUI_APP SOURCES ${SRC} DEPENDS sfml-graphics sfml-window sfml-system - INSTALL_RESOURCES_DIR) + RESOURCES_DIR resources)