@@ -6,29 +6,32 @@ project(CMakeSFMLProject LANGUAGES CXX)
6
6
option (CMAKESFMLPROJECT_STATIC_LIBS "Link SFML libraries statically?" OFF )
7
7
option (CMAKESFMLPROJECT_STATIC_STD_LIBS "Use statically linked standard/runtime libraries? This option must match the one used for SFML." OFF )
8
8
9
+ # Find all source files
10
+ file (GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR} /src/*.cpp ${PROJECT_SOURCE_DIR} /src/*.hpp)
11
+
9
12
# Tell CMake to build a executable
10
- add_executable (${PROJECT_NAME} src/main.cpp )
13
+ add_executable (${PROJECT_NAME} ${SOURCE_FILES} )
11
14
12
15
# CMake SFML Project uses C++17 features
13
16
target_compile_features (${PROJECT_NAME} PRIVATE cxx_std_17)
14
17
set_target_properties (${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS NO CXX_STANDARD_REQUIRED YES )
15
18
16
19
# Make sure that the runtime library gets linked statically
17
20
if (CMAKESFMLPROJECT_STATIC_STD_LIBS)
18
- if (NOT CMAKESFMLPROJECT_STATIC_LIBS)
19
- message ("\n -> If you check CMAKESFMLPROJECT_STATIC_STD_LIBS, you also need to check CMAKESFMLPROJECT_STATIC_LIBS." )
20
- message ("-> It would lead to multiple runtime environments which results in undefined behavior.\n " )
21
- elseif (WIN32 AND MSVC )
22
- set_property (TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" )
23
- elseif (CMAKE_COMPILER_IS_GNUCXX)
24
- # Note: Doesn't work for TDM compiler, since it's compiling the runtime libs statically by default
25
- target_compile_options (${PROJECT_NAME} PRIVATE -static )
26
- endif ()
21
+ if (NOT CMAKESFMLPROJECT_STATIC_LIBS)
22
+ message ("\n -> If you check CMAKESFMLPROJECT_STATIC_STD_LIBS, you also need to check CMAKESFMLPROJECT_STATIC_LIBS." )
23
+ message ("-> It would lead to multiple runtime environments which results in undefined behavior.\n " )
24
+ elseif (WIN32 AND MSVC )
25
+ set_property (TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" )
26
+ elseif (CMAKE_COMPILER_IS_GNUCXX)
27
+ # Note: Doesn't work for TDM compiler, since it's compiling the runtime libs statically by default
28
+ target_compile_options (${PROJECT_NAME} PRIVATE -static )
29
+ endif ()
27
30
endif ()
28
31
29
32
# Request static SFML libraries when building statically
30
33
if (CMAKESFMLPROJECT_STATIC_LIBS)
31
- set (SFML_STATIC_LIBRARIES TRUE )
34
+ set (SFML_STATIC_LIBRARIES TRUE )
32
35
endif ()
33
36
34
37
# Find SFML
@@ -39,4 +42,4 @@ target_link_libraries(${PROJECT_NAME} sfml-graphics)
39
42
40
43
# Install executable
41
44
install (TARGETS ${PROJECT_NAME}
42
- RUNTIME DESTINATION .)
45
+ RUNTIME DESTINATION .)
0 commit comments