-
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add missing files to lasagna master exercise (#838)
- Loading branch information
Showing
3 changed files
with
18,003 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Get the exercise name from the current directory | ||
get_filename_component(exercise ${CMAKE_CURRENT_SOURCE_DIR} NAME) | ||
|
||
# Basic CMake project | ||
cmake_minimum_required(VERSION 3.5.1) | ||
|
||
# Name the project after the exercise | ||
project(${exercise} CXX) | ||
|
||
# Get a source filename from the exercise name by replacing -'s with _'s | ||
string(REPLACE "-" "_" file ${exercise}) | ||
|
||
# Implementation could be only a header | ||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.cpp) | ||
set(exercise_cpp ${file}.cpp) | ||
else() | ||
set(exercise_cpp "") | ||
endif() | ||
|
||
# Use the common Catch library? | ||
if(EXERCISM_COMMON_CATCH) | ||
# For Exercism track development only | ||
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h $<TARGET_OBJECTS:catchlib>) | ||
elseif(EXERCISM_TEST_SUITE) | ||
# The Exercism test suite is being run, the Docker image already | ||
# includes a pre-built version of Catch. | ||
find_package(Catch2 REQUIRED) | ||
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h) | ||
target_link_libraries(${exercise} PRIVATE Catch2::Catch2WithMain) | ||
# When Catch is installed system wide we need to include a different | ||
# header, we need this define to use the correct one. | ||
target_compile_definitions(${exercise} PRIVATE EXERCISM_TEST_SUITE) | ||
else() | ||
# Build executable from sources and headers | ||
add_executable(${exercise} ${file}_test.cpp ${exercise_cpp} ${file}.h test/tests-main.cpp) | ||
endif() | ||
|
||
set_target_properties(${exercise} PROPERTIES | ||
CXX_STANDARD 17 | ||
CXX_STANDARD_REQUIRED OFF | ||
CXX_EXTENSIONS OFF | ||
) | ||
|
||
set(CMAKE_BUILD_TYPE Debug) | ||
|
||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "(GNU|Clang)") | ||
set_target_properties(${exercise} PROPERTIES | ||
COMPILE_FLAGS "-Wall -Wextra -Wpedantic -Werror" | ||
) | ||
endif() | ||
|
||
# Configure to run all the tests? | ||
if(${EXERCISM_RUN_ALL_TESTS}) | ||
target_compile_definitions(${exercise} PRIVATE EXERCISM_RUN_ALL_TESTS) | ||
endif() | ||
|
||
# Tell MSVC not to warn us about unchecked iterators in debug builds | ||
if(${MSVC}) | ||
set_target_properties(${exercise} PROPERTIES | ||
COMPILE_DEFINITIONS_DEBUG _SCL_SECURE_NO_WARNINGS) | ||
endif() | ||
|
||
# Run the tests on every build | ||
add_custom_target(test_${exercise} ALL DEPENDS ${exercise} COMMAND ${exercise}) |
Oops, something went wrong.