i
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
project(Hw5)
|
project(Hw6)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
@@ -7,29 +7,39 @@ set(CMAKE_CXX_STANDARD 17)
|
|||||||
# Manually specifying all the source files.
|
# Manually specifying all the source files.
|
||||||
#
|
#
|
||||||
set(HEADER_FILES
|
set(HEADER_FILES
|
||||||
WordTree.hpp
|
Pattern.hpp
|
||||||
rlutil.h)
|
PatternAcorn.hpp
|
||||||
set(SOURCE_FILES
|
PatternBlinker.hpp
|
||||||
WordTree.cpp )
|
PatternBlock.hpp
|
||||||
set(UNIT_TEST_FILES
|
PatternGlider.hpp
|
||||||
TestWordTree.cpp)
|
PatternGosperGliderGun.hpp
|
||||||
|
LifeSimulator.hpp
|
||||||
|
Renderer.hpp
|
||||||
|
RendererConsole.hpp)
|
||||||
|
|
||||||
add_executable(TypeAhead ${HEADER_FILES} ${SOURCE_FILES} main.cpp )
|
set(SOURCE_FILES
|
||||||
add_executable(UnitTestRunner ${HEADER_FILES} ${SOURCE_FILES} ${UNIT_TEST_FILES})
|
PatternAcorn.cpp
|
||||||
|
PatternBlinker.cpp
|
||||||
|
PatternBlock.cpp
|
||||||
|
PatternGlider.cpp
|
||||||
|
PatternGosperGliderGun.cpp
|
||||||
|
LifeSimulator.cpp
|
||||||
|
RendererConsole.cpp
|
||||||
|
main.cpp)
|
||||||
|
|
||||||
|
|
||||||
|
add_executable(ConwaysLife ${HEADER_FILES} ${SOURCE_FILES})
|
||||||
|
|
||||||
#
|
#
|
||||||
# We want the C++ 17 standard for our project
|
# We want the C++ 17 standard for our project
|
||||||
#
|
#
|
||||||
set_property(TARGET TypeAhead PROPERTY CXX_STANDARD 17)
|
set_property(TARGET ConwaysLife PROPERTY CXX_STANDARD 17)
|
||||||
set_property(TARGET UnitTestRunner PROPERTY CXX_STANDARD 17)
|
|
||||||
|
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
target_compile_options(TypeAhead PRIVATE /W4 /permissive-)
|
target_compile_options(ConwaysLife PRIVATE /W4 /permissive-)
|
||||||
target_compile_options(UnitTestRunner PRIVATE /W4 /permissive-)
|
|
||||||
set_target_properties(UnitTestRunner PROPERTIES LINK_FLAGS "/STACK:10000000")
|
|
||||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
target_compile_options(TypeAhead PRIVATE -Wall -Wextra -pedantic -Wl,--stack,10000000 -O3)
|
target_compile_options(ConwaysLife PRIVATE -Wall -Wextra -pedantic -Wl,--stack,10000000 -O3)
|
||||||
target_compile_options(UnitTestRunner PRIVATE -Wall -Wextra -pedantic -Wl,--stack,10000000 -O3)
|
|
||||||
endif()
|
endif()
|
||||||
#
|
#
|
||||||
# Prepare a pre-build step to run clang-format over all the [ch]pp source files.
|
# Prepare a pre-build step to run clang-format over all the [ch]pp source files.
|
||||||
@@ -42,7 +52,7 @@ if (CLANG_FORMAT)
|
|||||||
# file system locations for use in putting together the clang-format command line
|
# file system locations for use in putting together the clang-format command line
|
||||||
#
|
#
|
||||||
unset(SOURCE_FILES_PATHS)
|
unset(SOURCE_FILES_PATHS)
|
||||||
foreach(SOURCE_FILE ${HEADER_FILES} ${SOURCE_FILES} ${UNIT_TEST_FILES} main.cpp)
|
foreach(SOURCE_FILE ${HEADER_FILES} ${SOURCE_FILES})
|
||||||
get_source_file_property(WHERE ${SOURCE_FILE} LOCATION)
|
get_source_file_property(WHERE ${SOURCE_FILE} LOCATION)
|
||||||
set(SOURCE_FILES_PATHS ${SOURCE_FILES_PATHS} ${WHERE})
|
set(SOURCE_FILES_PATHS ${SOURCE_FILES_PATHS} ${WHERE})
|
||||||
endforeach()
|
endforeach()
|
||||||
@@ -61,34 +71,8 @@ if (CLANG_FORMAT)
|
|||||||
#
|
#
|
||||||
# This makes the clang-format target a dependency of the main GoogleTestIntro project
|
# This makes the clang-format target a dependency of the main GoogleTestIntro project
|
||||||
#
|
#
|
||||||
add_dependencies(TypeAhead ClangFormat)
|
add_dependencies(ConwaysLife ClangFormat)
|
||||||
else()
|
else()
|
||||||
message("Unable to find clang-format")
|
message("Unable to find clang-format")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)
|
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
|
||||||
RESULT_VARIABLE result
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
|
||||||
if(result)
|
|
||||||
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
|
|
||||||
endif()
|
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
|
||||||
RESULT_VARIABLE result
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
|
||||||
if(result)
|
|
||||||
message(FATAL_ERROR "Build step for googletest failed: ${result}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Prevent overriding the parent project's compiler/linker
|
|
||||||
# settings on Windows
|
|
||||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
||||||
|
|
||||||
# Add googletest directly to our build. This defines
|
|
||||||
# the gtest and gtest_main targets.
|
|
||||||
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
|
|
||||||
EXCLUDE_FROM_ALL)
|
|
||||||
|
|
||||||
# Now simply link against gtest or gtest_main as needed. Eg
|
|
||||||
target_link_libraries(UnitTestRunner gtest_main)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user