Skip to content

Commit edd6156

Browse files
ChrisThrashereXpl0it3r
authored andcommitted
Explicitly write out executable name
While using ${PROJECT_NAME} for simple single-executable projects isn't an awful idea, it scales poorly. If you want to add tests or a library or any other targets, it becomes awkward to keep using ${PROJECT_NAME} with various prefixes and suffixes to ensure all targets have unique names. The readability benefits of spelling out the name outweight the potential copy-paste-ability of using ${PROJECT_NAME} to name your executable.
1 parent edf38e5 commit edd6156

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ project(CMakeSFMLProject LANGUAGES CXX)
66
file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/src/*.cpp ${PROJECT_SOURCE_DIR}/src/*.hpp)
77

88
# Tell CMake to build a executable
9-
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
9+
add_executable(CMakeSFMLProject ${SOURCE_FILES})
1010

1111
# CMake SFML Project uses C++17 features
12-
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
12+
target_compile_features(CMakeSFMLProject PRIVATE cxx_std_17)
1313

1414
# Find SFML
1515
find_package(SFML 2.5 COMPONENTS graphics REQUIRED)
1616

1717
# Link SFML
18-
target_link_libraries(${PROJECT_NAME} PRIVATE sfml-graphics)
18+
target_link_libraries(CMakeSFMLProject PRIVATE sfml-graphics)
1919

2020
# Install executable
21-
install(TARGETS ${PROJECT_NAME}
21+
install(TARGETS CMakeSFMLProject
2222
RUNTIME DESTINATION .)

0 commit comments

Comments
 (0)