加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CMakeLists.txt 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
Michael Hirsch 提交于 2021-03-05 15:29 . add windows test
cmake_minimum_required(VERSION 3.7...3.20)
project(2048 LANGUAGES CXX)
include(CTest)
set(SOURCES src/2048.cpp src/gameboard.cpp src/gameboard-graphics.cpp src/game.cpp src/game-graphics.cpp src/game-input.cpp src/game-pregamemenu.cpp src/global.cpp src/loadresource.cpp src/menu.cpp src/menu-graphics.cpp src/saveresource.cpp src/scores.cpp src/scores-graphics.cpp src/statistics.cpp src/statistics-graphics.cpp src/tile.cpp src/tile-graphics.cpp)
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
string(APPEND CMAKE_CXX_FLAGS " -Wall")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
string(APPEND CMAKE_CXX_FLAGS " -Wall")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Intel)
if(WIN32)
string(APPEND CMAKE_CXX_FLAGS " /W3")
else()
string(APPEND CMAKE_CXX_FLAGS " -w2")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL PGI)
string(APPEND CMAKE_CXX_FLAGS " -a")
endif()
add_executable(2048 ${SOURCES})
target_include_directories(2048 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/headers/)
target_compile_features(2048 PRIVATE cxx_std_14)
# --- test
find_program(PWSH NAMES pwsh powershell)
if(PWSH)
add_test(NAME basic COMMAND ${PWSH} -c \"echo 4 | $<TARGET_FILE:2048>\")
elseif(UNIX)
add_test(NAME basic COMMAND sh -c "echo 4 | $<TARGET_FILE:2048>")
endif()
# --- install
install(TARGETS 2048
RUNTIME DESTINATION bin)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data
DESTINATION ${CMAKE_INSTALL_PREFIX})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化