Skip to content

Commit 204a1c6

Browse files
committed
clean up cmake files
1 parent 2b137a1 commit 204a1c6

File tree

3 files changed

+13
-27
lines changed

3 files changed

+13
-27
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ project(
99
)
1010

1111
find_package(glad CONFIG REQUIRED)
12-
find_package(SFML COMPONENTS system window graphics CONFIG REQUIRED)
12+
find_package(SFML COMPONENTS window CONFIG REQUIRED)
1313
find_package(glm CONFIG REQUIRED)
1414

1515
add_subdirectory(library)

app/CMakeLists.txt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1+
# Define executable and its properties
12
add_executable(${PROJECT_NAME} App.cpp)
2-
3-
# depends on CoreLibrary
4-
target_link_libraries(${PROJECT_NAME} PRIVATE CoreLibrary)
5-
6-
# depends on SFML
7-
target_link_libraries(${PROJECT_NAME} PRIVATE sfml-system sfml-window)
8-
9-
# set the output directory for the executable
3+
target_link_libraries(${PROJECT_NAME} PRIVATE Core)
4+
target_link_libraries(${PROJECT_NAME} PRIVATE sfml-window)
105
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${PROJECT_NAME})
116

12-
# copy resources directory after build
7+
# Copy resources directory after build
138
add_custom_command(
149
TARGET ${PROJECT_NAME} POST_BUILD
1510
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/resources $<TARGET_FILE_DIR:${PROJECT_NAME}>/resources

library/CMakeLists.txt

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,26 @@
11
set(INCROOT ${PROJECT_SOURCE_DIR}/library/include/Core)
22
set(SRCROOT ${PROJECT_SOURCE_DIR}/library/src/Core)
33

4-
# all header files
4+
# Define header and source file lists
55
set(LIBRARY_HEADERS
66
${INCROOT}/Statics.hpp
77
${INCROOT}/Camera.hpp
88
${INCROOT}/Shader.hpp
99
)
1010

11-
# all source files
1211
set(LIBRARY_SOURCES
1312
${SRCROOT}/Statics.cpp
1413
${SRCROOT}/Camera.cpp
1514
${SRCROOT}/Shader.cpp
1615
)
1716

18-
# define library
19-
add_library(CoreLibrary STATIC ${LIBRARY_HEADERS} ${LIBRARY_SOURCES})
17+
# Define library and its properties
18+
add_library(Core STATIC ${LIBRARY_HEADERS} ${LIBRARY_SOURCES})
19+
target_include_directories(Core PUBLIC ${PROJECT_SOURCE_DIR}/library/include)
20+
target_link_libraries(Core PUBLIC glad::glad)
21+
target_link_libraries(Core PUBLIC glm::glm)
22+
target_compile_features(Core PUBLIC cxx_std_17)
2023

21-
# we need this directory, and users of our library will need it too
22-
target_include_directories(CoreLibrary PUBLIC ${PROJECT_SOURCE_DIR}/library/include)
23-
24-
# depends on glad
25-
target_link_libraries(CoreLibrary PUBLIC glad::glad)
26-
27-
# depends on glm
28-
target_link_libraries(CoreLibrary PUBLIC glm::glm)
29-
30-
# all users of this library will need at least C++17
31-
target_compile_features(CoreLibrary PUBLIC cxx_std_17)
32-
33-
# IDEs should put the headers and sources in a nice place
24+
# Group headers and sources for IDE
3425
source_group(TREE ${INCROOT} PREFIX "Headers" FILES ${LIBRARY_HEADERS})
3526
source_group(TREE ${SRCROOT} PREFIX "Sources" FILES ${LIBRARY_SOURCES})

0 commit comments

Comments
 (0)