From a40ef79a18b16fe47ce7eecb7a8d8f6b42b9e5d0 Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Thu, 21 Feb 2013 20:25:11 +0100 Subject: [PATCH] Added source file groups in CMake files (for better organization of sources when opening SFML projects in IDEs) --- cmake/Macros.cmake | 3 ++ src/SFML/Audio/CMakeLists.txt | 1 + src/SFML/Graphics/CMakeLists.txt | 56 ++++++++++++++++++++------------ src/SFML/Main/CMakeLists.txt | 8 ++++- src/SFML/Network/CMakeLists.txt | 2 ++ src/SFML/System/CMakeLists.txt | 11 ++++--- src/SFML/Window/CMakeLists.txt | 15 +++++---- 7 files changed, 63 insertions(+), 33 deletions(-) diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake index 729ed306..224407b0 100644 --- a/cmake/Macros.cmake +++ b/cmake/Macros.cmake @@ -205,6 +205,9 @@ macro(sfml_add_example target) # parse the arguments sfml_parse_arguments(THIS "SOURCES;DEPENDS" "GUI_APP" ${ARGN}) + # set a source group for the source files + source_group("" FILES ${THIS_SOURCES}) + # create the target if(THIS_GUI_APP AND WINDOWS) add_executable(${target} WIN32 ${THIS_SOURCES}) diff --git a/src/SFML/Audio/CMakeLists.txt b/src/SFML/Audio/CMakeLists.txt index 33874818..818b9b6c 100644 --- a/src/SFML/Audio/CMakeLists.txt +++ b/src/SFML/Audio/CMakeLists.txt @@ -28,6 +28,7 @@ set(SRC ${SRCROOT}/SoundStream.cpp ${INCROOT}/SoundStream.hpp ) +source_group("" FILES ${SRC}) # let CMake know about our additional audio libraries paths (on Windows and OSX) if(WINDOWS) diff --git a/src/SFML/Graphics/CMakeLists.txt b/src/SFML/Graphics/CMakeLists.txt index 3058c8de..ba74b71e 100644 --- a/src/SFML/Graphics/CMakeLists.txt +++ b/src/SFML/Graphics/CMakeLists.txt @@ -7,7 +7,6 @@ set(SRC ${INCROOT}/BlendMode.hpp ${SRCROOT}/Color.cpp ${INCROOT}/Color.hpp - ${INCROOT}/Drawable.hpp ${INCROOT}/Export.hpp ${SRCROOT}/Font.cpp ${INCROOT}/Font.hpp @@ -25,30 +24,12 @@ set(SRC ${INCROOT}/RenderStates.hpp ${SRCROOT}/RenderTexture.cpp ${INCROOT}/RenderTexture.hpp - ${SRCROOT}/RenderTextureImpl.cpp - ${SRCROOT}/RenderTextureImpl.hpp - ${SRCROOT}/RenderTextureImplFBO.cpp - ${SRCROOT}/RenderTextureImplFBO.hpp - ${SRCROOT}/RenderTextureImplDefault.cpp - ${SRCROOT}/RenderTextureImplDefault.hpp ${SRCROOT}/RenderTarget.cpp ${INCROOT}/RenderTarget.hpp ${SRCROOT}/RenderWindow.cpp ${INCROOT}/RenderWindow.hpp ${SRCROOT}/Shader.cpp ${INCROOT}/Shader.hpp - ${SRCROOT}/Shape.cpp - ${INCROOT}/Shape.hpp - ${SRCROOT}/CircleShape.cpp - ${INCROOT}/CircleShape.hpp - ${SRCROOT}/RectangleShape.cpp - ${INCROOT}/RectangleShape.hpp - ${SRCROOT}/ConvexShape.cpp - ${INCROOT}/ConvexShape.hpp - ${SRCROOT}/Sprite.cpp - ${INCROOT}/Sprite.hpp - ${SRCROOT}/Text.cpp - ${INCROOT}/Text.hpp ${SRCROOT}/Texture.cpp ${INCROOT}/Texture.hpp ${SRCROOT}/TextureSaver.cpp @@ -61,11 +42,46 @@ set(SRC ${INCROOT}/View.hpp ${SRCROOT}/Vertex.cpp ${INCROOT}/Vertex.hpp +) +source_group("" FILES ${SRC}) + +# drawables sources +set(DRAWABLES_SRC + ${INCROOT}/Drawable.hpp + ${SRCROOT}/Shape.cpp + ${INCROOT}/Shape.hpp + ${SRCROOT}/CircleShape.cpp + ${INCROOT}/CircleShape.hpp + ${SRCROOT}/RectangleShape.cpp + ${INCROOT}/RectangleShape.hpp + ${SRCROOT}/ConvexShape.cpp + ${INCROOT}/ConvexShape.hpp + ${SRCROOT}/Sprite.cpp + ${INCROOT}/Sprite.hpp + ${SRCROOT}/Text.cpp + ${INCROOT}/Text.hpp ${SRCROOT}/VertexArray.cpp ${INCROOT}/VertexArray.hpp +) +source_group("drawables" FILES ${DRAWABLES_SRC}) + +# render-texture sources +set(RENDER_TEXTURE_SRC + ${SRCROOT}/RenderTextureImpl.cpp + ${SRCROOT}/RenderTextureImpl.hpp + ${SRCROOT}/RenderTextureImplFBO.cpp + ${SRCROOT}/RenderTextureImplFBO.hpp + ${SRCROOT}/RenderTextureImplDefault.cpp + ${SRCROOT}/RenderTextureImplDefault.hpp +) +source_group("render texture" FILES ${RENDER_TEXTURE_SRC}) + +# stb_image sources +set(STB_SRC ${SRCROOT}/stb_image/stb_image.h ${SRCROOT}/stb_image/stb_image_write.h ) +source_group("stb_image" FILES ${STB_SRC}) # let CMake know about our additional graphics libraries paths (on Windows and OSX) if(WINDOWS OR MACOSX) @@ -114,6 +130,6 @@ endif() # define the sfml-graphics target sfml_add_library(sfml-graphics - SOURCES ${SRC} + SOURCES ${SRC} ${DRAWABLES_SRC} ${RENDER_TEXTURE_SRC} ${STB_SRC} DEPENDS sfml-window sfml-system EXTERNAL_LIBS ${GRAPHICS_EXT_LIBS}) diff --git a/src/SFML/Main/CMakeLists.txt b/src/SFML/Main/CMakeLists.txt index 8991db46..55c0d161 100644 --- a/src/SFML/Main/CMakeLists.txt +++ b/src/SFML/Main/CMakeLists.txt @@ -1,6 +1,12 @@ +# sources +set(SRC + ${PROJECT_SOURCE_DIR}/src/SFML/Main/SFML_Main.cpp +) +source_group("" FILES ${SRC}) + # define the sfml-main target -add_library(sfml-main STATIC ${PROJECT_SOURCE_DIR}/src/SFML/Main/SFML_Main.cpp) +add_library(sfml-main STATIC ${SRC}) # set the debug suffix set_target_properties(sfml-main PROPERTIES DEBUG_POSTFIX -d) diff --git a/src/SFML/Network/CMakeLists.txt b/src/SFML/Network/CMakeLists.txt index 8dd27d37..fdf39664 100644 --- a/src/SFML/Network/CMakeLists.txt +++ b/src/SFML/Network/CMakeLists.txt @@ -42,6 +42,8 @@ else() ) endif() +source_group("" FILES ${SRC}) + # build the list of external libraries to link set(NETWORK_EXT_LIBS) if(WINDOWS) diff --git a/src/SFML/System/CMakeLists.txt b/src/SFML/System/CMakeLists.txt index 6efd948c..fc8ea5cd 100644 --- a/src/SFML/System/CMakeLists.txt +++ b/src/SFML/System/CMakeLists.txt @@ -34,11 +34,11 @@ set(SRC ${INCROOT}/Vector3.hpp ${INCROOT}/Vector3.inl ) +source_group("" FILES ${SRC}) # add platform specific sources if(WINDOWS) - set(SRC - ${SRC} + set(PLATFORM_SRC ${SRCROOT}/Win32/ClockImpl.cpp ${SRCROOT}/Win32/ClockImpl.hpp ${SRCROOT}/Win32/MutexImpl.cpp @@ -50,9 +50,9 @@ if(WINDOWS) ${SRCROOT}/Win32/ThreadLocalImpl.cpp ${SRCROOT}/Win32/ThreadLocalImpl.hpp ) + source_group("windows" FILES ${PLATFORM_SRC}) else() - set(SRC - ${SRC} + set(PLATFORM_SRC ${SRCROOT}/Unix/ClockImpl.cpp ${SRCROOT}/Unix/ClockImpl.hpp ${SRCROOT}/Unix/MutexImpl.cpp @@ -64,6 +64,7 @@ else() ${SRCROOT}/Unix/ThreadLocalImpl.cpp ${SRCROOT}/Unix/ThreadLocalImpl.hpp ) + source_group("unix" FILES ${PLATFORM_SRC}) endif() # build the list of external libraries to link @@ -77,5 +78,5 @@ endif() # define the sfml-system target sfml_add_library(sfml-system - SOURCES ${SRC} + SOURCES ${SRC} ${PLATFORM_SRC} EXTERNAL_LIBS ${SYSTEM_EXT_LIBS}) diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index 591dff73..67e17b9f 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -33,11 +33,11 @@ set(SRC ${SRCROOT}/WindowImpl.hpp ${INCROOT}/WindowStyle.hpp ) +source_group("" FILES ${SRC}) # add platform specific sources if(WINDOWS) - set(SRC - ${SRC} + set(PLATFORM_SRC ${SRCROOT}/Win32/WglContext.cpp ${SRCROOT}/Win32/WglContext.hpp ${SRCROOT}/Win32/InputImpl.cpp @@ -48,9 +48,9 @@ if(WINDOWS) ${SRCROOT}/Win32/WindowImplWin32.cpp ${SRCROOT}/Win32/WindowImplWin32.hpp ) + source_group("windows" FILES ${PLATFORM_SRC}) elseif(LINUX) - set(SRC - ${SRC} + set(PLATFORM_SRC ${SRCROOT}/Linux/Display.cpp ${SRCROOT}/Linux/Display.hpp ${SRCROOT}/Linux/GlxContext.cpp @@ -63,9 +63,9 @@ elseif(LINUX) ${SRCROOT}/Linux/WindowImplX11.cpp ${SRCROOT}/Linux/WindowImplX11.hpp ) + source_group("linux" FILES ${PLATFORM_SRC}) else() # MACOSX - set(SRC - ${SRC} + set(PLATFORM_SRC ${SRCROOT}/OSX/cpp_objc_conversion.h ${SRCROOT}/OSX/cpp_objc_conversion.mm ${SRCROOT}/OSX/cg_sf_conversion.hpp @@ -97,6 +97,7 @@ else() # MACOSX ${SRCROOT}/OSX/AutoreleasePoolWrapper.h ${SRCROOT}/OSX/AutoreleasePoolWrapper.mm ) + source_group("mac" FILES ${PLATFORM_SRC}) endif() # find external libraries @@ -122,6 +123,6 @@ endif() # define the sfml-window target sfml_add_library(sfml-window - SOURCES ${SRC} + SOURCES ${SRC} ${PLATFORM_SRC} DEPENDS sfml-system EXTERNAL_LIBS ${WINDOW_EXT_LIBS})