Skip to content

Commit

Permalink
build: rename sample targets (#78)
Browse files Browse the repository at this point in the history
* build: rename executable to `generate_sequence`

* build: rename library to `sequence`

* build: rename test target to `sequence_test`
  • Loading branch information
threeal authored Dec 17, 2023
1 parent 50bfa50 commit 264f6f7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
42 changes: 21 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ cpmusepackagelock(package-lock)
cpmgetpackage(argparse)
cpmgetpackage(CheckWarning.cmake)

add_library(my_fibonacci src/sequence.cpp)
add_library(sequence src/sequence.cpp)

target_sources(
my_fibonacci PUBLIC FILE_SET HEADERS
sequence PUBLIC FILE_SET HEADERS
BASE_DIRS include
FILES include/my_fibonacci/sequence.hpp
)

set_property(TARGET my_fibonacci PROPERTY CXX_STANDARD 11)
set_property(TARGET sequence PROPERTY CXX_STANDARD 11)
if(BUILD_TESTING)
target_check_warning(my_fibonacci)
target_check_warning(sequence)
endif()

add_executable(my_fibonacci_main src/main.cpp)
target_link_libraries(my_fibonacci_main PUBLIC argparse my_fibonacci)
set_property(TARGET my_fibonacci_main PROPERTY CXX_STANDARD 11)
add_executable(generate_sequence src/main.cpp)
target_link_libraries(generate_sequence PUBLIC argparse sequence)
set_property(TARGET generate_sequence PROPERTY CXX_STANDARD 11)
if(BUILD_TESTING)
target_check_warning(my_fibonacci_main)
target_check_warning(generate_sequence)
endif()

if(BUILD_TESTING)
Expand All @@ -52,28 +52,28 @@ if(BUILD_TESTING)
cpmgetpackage(Catch2)
include("${Catch2_SOURCE_DIR}/extras/Catch.cmake")

get_target_property(my_fibonacci_SOURCES my_fibonacci SOURCES)
add_executable(my_fibonacci_test test/sequence_test.cpp ${my_fibonacci_SOURCES})
get_target_property(sequence_SOURCES sequence SOURCES)
add_executable(sequence_test test/sequence_test.cpp ${sequence_SOURCES})

get_target_property(my_fibonacci_HEADER_DIRS my_fibonacci HEADER_DIRS)
get_target_property(my_fibonacci_HEADER_SET my_fibonacci HEADER_SET)
get_target_property(sequence_HEADER_DIRS sequence HEADER_DIRS)
get_target_property(sequence_HEADER_SET sequence HEADER_SET)
target_sources(
my_fibonacci_test PRIVATE FILE_SET HEADERS
BASE_DIRS ${my_fibonacci_HEADER_DIRS}
FILES ${my_fibonacci_HEADER_SET}
sequence_test PRIVATE FILE_SET HEADERS
BASE_DIRS ${sequence_HEADER_DIRS}
FILES ${sequence_HEADER_SET}
)

target_link_libraries(my_fibonacci_test PRIVATE Catch2::Catch2WithMain)
target_link_libraries(sequence_test PRIVATE Catch2::Catch2WithMain)

target_check_warning(my_fibonacci_test)
target_compile_options(my_fibonacci_test PRIVATE --coverage -O0)
target_link_options(my_fibonacci_test PRIVATE --coverage)
target_check_warning(sequence_test)
target_compile_options(sequence_test PRIVATE --coverage -O0)
target_link_options(sequence_test PRIVATE --coverage)

catch_discover_tests(my_fibonacci_test)
catch_discover_tests(sequence_test)
endif()

install(
TARGETS my_fibonacci my_fibonacci_main
TARGETS generate_sequence sequence
EXPORT my_fibonacci_targets
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <my_fibonacci/sequence.hpp>

int main(int argc, char** argv) {
argparse::ArgumentParser program("my_fibonacci_main");
argparse::ArgumentParser program("generate_sequence");
program.add_description(
"Generate a Fibonacci sequence up to the given number of terms.");
program.add_argument("n").help("The number of terms").scan<'i', int>();
Expand Down

0 comments on commit 264f6f7

Please sign in to comment.