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.
This commit is contained in:
Chris Thrasher 2022-06-12 10:48:48 -06:00 committed by Lukas Dürrenberger
parent 539483d329
commit 65fef85b30
15 changed files with 33 additions and 79 deletions

View File

@ -1,8 +1,5 @@
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/X11)
# all source files # all source files
set(SRC ${SRCROOT}/X11.cpp) set(SRC X11.cpp)
# define the X11 target # define the X11 target
sfml_add_example(X11Example GUI_APP sfml_add_example(X11Example GUI_APP

View File

@ -1,6 +1,3 @@
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/cocoa)
# Usage: compile_xib(INPUT path/to/file.xib OUTPUT path/to/file.nib) # Usage: compile_xib(INPUT path/to/file.xib OUTPUT path/to/file.nib)
function(compile_xib) function(compile_xib)
cmake_parse_arguments(THIS "" "INPUT;OUTPUT" "" ${ARGN}) cmake_parse_arguments(THIS "" "INPUT;OUTPUT" "" ${ARGN})
@ -30,22 +27,22 @@ function(compile_xib)
endfunction() endfunction()
# all source files # all source files
set(SRC ${SRCROOT}/CocoaAppDelegate.h set(SRC CocoaAppDelegate.h
${SRCROOT}/CocoaAppDelegate.mm CocoaAppDelegate.mm
${SRCROOT}/NSString+stdstring.h NSString+stdstring.h
${SRCROOT}/NSString+stdstring.mm NSString+stdstring.mm
${SRCROOT}/main.m) 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 # all resource files
set(RESOURCES ${SRCROOT}/resources/icon.icns set(RESOURCES resources/icon.icns
${SRCROOT}/resources/tuffy.ttf resources/tuffy.ttf
${SRCROOT}/resources/logo.png resources/logo.png
${SRCROOT}/resources/blue.png resources/blue.png
${SRCROOT}/resources/green.png resources/green.png
${SRCROOT}/resources/red.png resources/red.png
${SRCROOT}/resources/Credits.rtf resources/Credits.rtf
${CMAKE_CURRENT_BINARY_DIR}/MainMenu.nib) ${CMAKE_CURRENT_BINARY_DIR}/MainMenu.nib)
set_source_files_properties(${RESOURCES} PROPERTIES set_source_files_properties(${RESOURCES} PROPERTIES
MACOSX_PACKAGE_LOCATION Resources) MACOSX_PACKAGE_LOCATION Resources)
@ -57,5 +54,5 @@ sfml_add_example(cocoa
DEPENDS SFML::System SFML::Window SFML::Graphics) DEPENDS SFML::System SFML::Window SFML::Graphics)
set_target_properties(cocoa PROPERTIES set_target_properties(cocoa PROPERTIES
MACOSX_BUNDLE TRUE 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) target_link_libraries(cocoa PRIVATE "-framework Cocoa" "-framework Foundation" SFML::Graphics)

View File

@ -1,8 +1,5 @@
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/ftp)
# all source files # all source files
set(SRC ${SRCROOT}/Ftp.cpp) set(SRC Ftp.cpp)
# define the ftp target # define the ftp target
sfml_add_example(ftp sfml_add_example(ftp

View File

@ -1,8 +1,5 @@
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/island)
# all source files # all source files
set(SRC ${SRCROOT}/Island.cpp) set(SRC Island.cpp)
# define the island target # define the island target
sfml_add_example(island GUI_APP sfml_add_example(island GUI_APP

View File

@ -1,8 +1,5 @@
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/joystick)
# all source files # all source files
set(SRC ${SRCROOT}/Joystick.cpp) set(SRC Joystick.cpp)
# define the joystick target # define the joystick target
sfml_add_example(joystick GUI_APP sfml_add_example(joystick GUI_APP

View File

@ -1,8 +1,5 @@
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/opengl)
# all source files # all source files
set(SRC ${SRCROOT}/OpenGL.cpp) set(SRC OpenGL.cpp)
if (SFML_OS_IOS) if (SFML_OS_IOS)
set(RESOURCES set(RESOURCES

View File

@ -1,10 +1,6 @@
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/shader)
# all source files # all source files
set(SRC set(SRC Effect.hpp
${SRCROOT}/Effect.hpp Shader.cpp)
${SRCROOT}/Shader.cpp)
# define the shader target # define the shader target
sfml_add_example(shader GUI_APP sfml_add_example(shader GUI_APP

View File

@ -1,10 +1,7 @@
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/sockets)
# all source files # all source files
set(SRC ${SRCROOT}/Sockets.cpp set(SRC Sockets.cpp
${SRCROOT}/TCP.cpp TCP.cpp
${SRCROOT}/UDP.cpp) UDP.cpp)
# define the sockets target # define the sockets target
sfml_add_example(sockets sfml_add_example(sockets

View File

@ -1,8 +1,5 @@
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/sound)
# all source files # all source files
set(SRC ${SRCROOT}/Sound.cpp) set(SRC Sound.cpp)
# define the sound target # define the sound target
sfml_add_example(sound sfml_add_example(sound

View File

@ -1,8 +1,5 @@
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/sound_capture)
# all source files # all source files
set(SRC ${SRCROOT}/SoundCapture.cpp) set(SRC SoundCapture.cpp)
# define the sound-capture target # define the sound-capture target
sfml_add_example(sound-capture sfml_add_example(sound-capture

View File

@ -1,8 +1,5 @@
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/tennis)
# all source files # all source files
set(SRC ${SRCROOT}/Tennis.cpp) set(SRC Tennis.cpp)
if (SFML_OS_IOS) if (SFML_OS_IOS)
set(RESOURCES set(RESOURCES
${CMAKE_CURRENT_SOURCE_DIR}/resources/ball.wav ${CMAKE_CURRENT_SOURCE_DIR}/resources/ball.wav

View File

@ -1,10 +1,7 @@
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/voip)
# all source files # all source files
set(SRC ${SRCROOT}/VoIP.cpp set(SRC VoIP.cpp
${SRCROOT}/Client.cpp Client.cpp
${SRCROOT}/Server.cpp) Server.cpp)
# define the voip target # define the voip target
sfml_add_example(voip sfml_add_example(voip

View File

@ -1,8 +1,5 @@
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/vulkan)
# all source files # all source files
set(SRC ${SRCROOT}/Vulkan.cpp) set(SRC Vulkan.cpp)
# define the window target # define the window target
sfml_add_example(vulkan GUI_APP sfml_add_example(vulkan GUI_APP

View File

@ -1,8 +1,5 @@
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/win32)
# all source files # all source files
set(SRC ${SRCROOT}/Win32.cpp) set(SRC Win32.cpp)
# define the win32 target # define the win32 target
sfml_add_example(win32 GUI_APP sfml_add_example(win32 GUI_APP

View File

@ -1,8 +1,5 @@
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/window)
# all source files # all source files
set(SRC ${SRCROOT}/Window.cpp) set(SRC Window.cpp)
# define the window target # define the window target
sfml_add_example(window GUI_APP sfml_add_example(window GUI_APP