From 65fef85b3065e463e09fe3f4796fb53dd3d56edf Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Sun, 12 Jun 2022 10:48:48 -0600 Subject: [PATCH] Simplify how examples are built CMake doesn't require absolute paths so we can safely remove SRCROOT and let implicit relative pathing achieve the same result with less work on our part. --- examples/X11/CMakeLists.txt | 5 +---- examples/cocoa/CMakeLists.txt | 31 ++++++++++++--------------- examples/ftp/CMakeLists.txt | 5 +---- examples/island/CMakeLists.txt | 5 +---- examples/joystick/CMakeLists.txt | 5 +---- examples/opengl/CMakeLists.txt | 5 +---- examples/shader/CMakeLists.txt | 8 ++----- examples/sockets/CMakeLists.txt | 9 +++----- examples/sound/CMakeLists.txt | 5 +---- examples/sound_capture/CMakeLists.txt | 5 +---- examples/tennis/CMakeLists.txt | 5 +---- examples/voip/CMakeLists.txt | 9 +++----- examples/vulkan/CMakeLists.txt | 5 +---- examples/win32/CMakeLists.txt | 5 +---- examples/window/CMakeLists.txt | 5 +---- 15 files changed, 33 insertions(+), 79 deletions(-) diff --git a/examples/X11/CMakeLists.txt b/examples/X11/CMakeLists.txt index 64aacec08..60692e2cb 100644 --- a/examples/X11/CMakeLists.txt +++ b/examples/X11/CMakeLists.txt @@ -1,8 +1,5 @@ - -set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/X11) - # all source files -set(SRC ${SRCROOT}/X11.cpp) +set(SRC X11.cpp) # define the X11 target sfml_add_example(X11Example GUI_APP diff --git a/examples/cocoa/CMakeLists.txt b/examples/cocoa/CMakeLists.txt index b23ff8c4d..731ac5189 100644 --- a/examples/cocoa/CMakeLists.txt +++ b/examples/cocoa/CMakeLists.txt @@ -1,6 +1,3 @@ - -set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/cocoa) - # Usage: compile_xib(INPUT path/to/file.xib OUTPUT path/to/file.nib) function(compile_xib) cmake_parse_arguments(THIS "" "INPUT;OUTPUT" "" ${ARGN}) @@ -30,22 +27,22 @@ function(compile_xib) endfunction() # all source files -set(SRC ${SRCROOT}/CocoaAppDelegate.h - ${SRCROOT}/CocoaAppDelegate.mm - ${SRCROOT}/NSString+stdstring.h - ${SRCROOT}/NSString+stdstring.mm - ${SRCROOT}/main.m) +set(SRC CocoaAppDelegate.h + CocoaAppDelegate.mm + NSString+stdstring.h + NSString+stdstring.mm + main.m) -compile_xib(INPUT "${SRCROOT}/MainMenu.xib" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/MainMenu.nib") +compile_xib(INPUT "MainMenu.xib" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/MainMenu.nib") # all resource files -set(RESOURCES ${SRCROOT}/resources/icon.icns - ${SRCROOT}/resources/tuffy.ttf - ${SRCROOT}/resources/logo.png - ${SRCROOT}/resources/blue.png - ${SRCROOT}/resources/green.png - ${SRCROOT}/resources/red.png - ${SRCROOT}/resources/Credits.rtf +set(RESOURCES resources/icon.icns + resources/tuffy.ttf + resources/logo.png + resources/blue.png + resources/green.png + resources/red.png + resources/Credits.rtf ${CMAKE_CURRENT_BINARY_DIR}/MainMenu.nib) set_source_files_properties(${RESOURCES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) @@ -57,5 +54,5 @@ sfml_add_example(cocoa DEPENDS SFML::System SFML::Window SFML::Graphics) set_target_properties(cocoa PROPERTIES MACOSX_BUNDLE TRUE - MACOSX_BUNDLE_INFO_PLIST ${SRCROOT}/resources/Cocoa-Info.plist) + MACOSX_BUNDLE_INFO_PLIST resources/Cocoa-Info.plist) target_link_libraries(cocoa PRIVATE "-framework Cocoa" "-framework Foundation" SFML::Graphics) diff --git a/examples/ftp/CMakeLists.txt b/examples/ftp/CMakeLists.txt index b1e8fc168..209ddb869 100644 --- a/examples/ftp/CMakeLists.txt +++ b/examples/ftp/CMakeLists.txt @@ -1,8 +1,5 @@ - -set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/ftp) - # all source files -set(SRC ${SRCROOT}/Ftp.cpp) +set(SRC Ftp.cpp) # define the ftp target sfml_add_example(ftp diff --git a/examples/island/CMakeLists.txt b/examples/island/CMakeLists.txt index c7be4ec42..1cae7a97a 100644 --- a/examples/island/CMakeLists.txt +++ b/examples/island/CMakeLists.txt @@ -1,8 +1,5 @@ - -set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/island) - # all source files -set(SRC ${SRCROOT}/Island.cpp) +set(SRC Island.cpp) # define the island target sfml_add_example(island GUI_APP diff --git a/examples/joystick/CMakeLists.txt b/examples/joystick/CMakeLists.txt index 195ff28fc..1d68c8e4c 100644 --- a/examples/joystick/CMakeLists.txt +++ b/examples/joystick/CMakeLists.txt @@ -1,8 +1,5 @@ - -set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/joystick) - # all source files -set(SRC ${SRCROOT}/Joystick.cpp) +set(SRC Joystick.cpp) # define the joystick target sfml_add_example(joystick GUI_APP diff --git a/examples/opengl/CMakeLists.txt b/examples/opengl/CMakeLists.txt index 81b052799..824c7535c 100644 --- a/examples/opengl/CMakeLists.txt +++ b/examples/opengl/CMakeLists.txt @@ -1,8 +1,5 @@ - -set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/opengl) - # all source files -set(SRC ${SRCROOT}/OpenGL.cpp) +set(SRC OpenGL.cpp) if (SFML_OS_IOS) set(RESOURCES diff --git a/examples/shader/CMakeLists.txt b/examples/shader/CMakeLists.txt index d4089adfe..0cdb7c4c2 100644 --- a/examples/shader/CMakeLists.txt +++ b/examples/shader/CMakeLists.txt @@ -1,10 +1,6 @@ - -set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/shader) - # all source files -set(SRC - ${SRCROOT}/Effect.hpp - ${SRCROOT}/Shader.cpp) +set(SRC Effect.hpp + Shader.cpp) # define the shader target sfml_add_example(shader GUI_APP diff --git a/examples/sockets/CMakeLists.txt b/examples/sockets/CMakeLists.txt index 93221ee8e..df517d31c 100644 --- a/examples/sockets/CMakeLists.txt +++ b/examples/sockets/CMakeLists.txt @@ -1,10 +1,7 @@ - -set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/sockets) - # all source files -set(SRC ${SRCROOT}/Sockets.cpp - ${SRCROOT}/TCP.cpp - ${SRCROOT}/UDP.cpp) +set(SRC Sockets.cpp + TCP.cpp + UDP.cpp) # define the sockets target sfml_add_example(sockets diff --git a/examples/sound/CMakeLists.txt b/examples/sound/CMakeLists.txt index 8369a3713..6d58a067f 100644 --- a/examples/sound/CMakeLists.txt +++ b/examples/sound/CMakeLists.txt @@ -1,8 +1,5 @@ - -set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/sound) - # all source files -set(SRC ${SRCROOT}/Sound.cpp) +set(SRC Sound.cpp) # define the sound target sfml_add_example(sound diff --git a/examples/sound_capture/CMakeLists.txt b/examples/sound_capture/CMakeLists.txt index ce416d60a..87380fddb 100644 --- a/examples/sound_capture/CMakeLists.txt +++ b/examples/sound_capture/CMakeLists.txt @@ -1,8 +1,5 @@ - -set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/sound_capture) - # all source files -set(SRC ${SRCROOT}/SoundCapture.cpp) +set(SRC SoundCapture.cpp) # define the sound-capture target sfml_add_example(sound-capture diff --git a/examples/tennis/CMakeLists.txt b/examples/tennis/CMakeLists.txt index 84c7a5f29..c2a752485 100644 --- a/examples/tennis/CMakeLists.txt +++ b/examples/tennis/CMakeLists.txt @@ -1,8 +1,5 @@ - -set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/tennis) - # all source files -set(SRC ${SRCROOT}/Tennis.cpp) +set(SRC Tennis.cpp) if (SFML_OS_IOS) set(RESOURCES ${CMAKE_CURRENT_SOURCE_DIR}/resources/ball.wav diff --git a/examples/voip/CMakeLists.txt b/examples/voip/CMakeLists.txt index a5e14c3f2..e6650393f 100644 --- a/examples/voip/CMakeLists.txt +++ b/examples/voip/CMakeLists.txt @@ -1,10 +1,7 @@ - -set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/voip) - # all source files -set(SRC ${SRCROOT}/VoIP.cpp - ${SRCROOT}/Client.cpp - ${SRCROOT}/Server.cpp) +set(SRC VoIP.cpp + Client.cpp + Server.cpp) # define the voip target sfml_add_example(voip diff --git a/examples/vulkan/CMakeLists.txt b/examples/vulkan/CMakeLists.txt index f9cd287cb..556b6c858 100644 --- a/examples/vulkan/CMakeLists.txt +++ b/examples/vulkan/CMakeLists.txt @@ -1,8 +1,5 @@ - -set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/vulkan) - # all source files -set(SRC ${SRCROOT}/Vulkan.cpp) +set(SRC Vulkan.cpp) # define the window target sfml_add_example(vulkan GUI_APP diff --git a/examples/win32/CMakeLists.txt b/examples/win32/CMakeLists.txt index 87c5c18ac..001f4bb30 100644 --- a/examples/win32/CMakeLists.txt +++ b/examples/win32/CMakeLists.txt @@ -1,8 +1,5 @@ - -set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/win32) - # all source files -set(SRC ${SRCROOT}/Win32.cpp) +set(SRC Win32.cpp) # define the win32 target sfml_add_example(win32 GUI_APP diff --git a/examples/window/CMakeLists.txt b/examples/window/CMakeLists.txt index f463289ca..2017bf7bb 100644 --- a/examples/window/CMakeLists.txt +++ b/examples/window/CMakeLists.txt @@ -1,8 +1,5 @@ - -set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/window) - # all source files -set(SRC ${SRCROOT}/Window.cpp) +set(SRC Window.cpp) # define the window target sfml_add_example(window GUI_APP