Skip to content

Commit c1cc403

Browse files
committed
Clean up a few spots
1 parent 754b054 commit c1cc403

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

cmake/template_src.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11

22
# Specify .cpp files
3+
set(TARGET_NAME {{project_name}})
34
set(SRC hello.cpp)
45

5-
# Specify the executable
6-
add_executable({{project_name}}-bin main.cpp ${SRC})
7-
target_link_libraries({{project_name}}-bin ${LIBRARIES})
8-
set_target_properties({{project_name}}-bin PROPERTIES OUTPUT_NAME {{project_name}})
6+
# Build an executable from main.cpp and all specified source files
7+
add_executable(${TARGET_NAME} main.cpp ${SRC})
8+
target_link_libraries(${TARGET_NAME} ${LIBRARIES})
99

10-
# Build a library
11-
add_library({{project_name}} ${SRC})
12-
target_link_libraries({{project_name}} ${LIBRARIES})
10+
# Build a library from all specified source files
11+
# This is required for using googletest
12+
add_library(${TARGET_NAME}-lib ${SRC})
13+
target_link_libraries(${TARGET_NAME}-lib ${LIBRARIES})
14+
set_target_properties(${TARGET_NAME}-lib PROPERTIES OUTPUT_NAME {{project_name}})
1315

1416
# vim:ft=cmake
1517

cmake/template_test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
include(ExternalProject)
22

3-
set(TARGET {{project_name}})
3+
set(TARGET {{project_name}}-lib)
44
set(GTEST_TARGET ${TARGET}_test)
55
file(GLOB_RECURSE TESTS_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
66

src/hello.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ void hello() {
99
}
1010

1111
std::string get_message() {
12+
// There's a mistake here
13+
// Try running `make check` and observe the failing test case
14+
// Then correct the line below and repeat
1215
return "Hellx, World!";
1316
}
1417

0 commit comments

Comments
 (0)