Permalink
Browse files

debug/release configurations, download at configure-time, catch CTest,

gcov
  • Loading branch information...
charlesyuan314 committed Jun 27, 2018
1 parent 07dcf48 commit bb6f5d162370e075d97a0560b1d16f7c30c05e3a
Showing with 105 additions and 13,344 deletions.
  1. +1 −0 environment/.gitignore
  2. +51 −56 environment/CMakeLists.txt
  3. +52 −0 environment/CMakeLists.txt.in
  4. +1 −1 environment/test/TestMain.cpp
  5. +0 −13,287 environment/test/catch.hpp
@@ -6,3 +6,4 @@ Testing/
coverage.base
coverage.info
coverage/
deps-download
@@ -6,7 +6,12 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O2 -Wall -Wextra -pedantic -Wno-unused-variable")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif(NOT CMAKE_BUILD_TYPE)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall -Wextra -pedantic -Wno-unused-variable -Qunused-arguments")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0 -Wall -Wextra -pedantic -Wno-unused-variable -Qunused-arguments")
# versions of cmake before 3.4 always link with -rdynamic on linux, which breaks static linkage with clang
# unfortunately travis right now only has cmake 3.2, so have to do this workaround for now
@@ -19,8 +24,8 @@ include_directories(${CMAKE_SOURCE_DIR}/error)
include_directories(${CMAKE_SOURCE_DIR}/logging)
include_directories(${CMAKE_SOURCE_DIR}/mapgen)
include_directories(${CMAKE_SOURCE_DIR}/model)
include_directories(${CMAKE_SOURCE_DIR}/replay)
include_directories(${CMAKE_SOURCE_DIR}/networking/common)
include_directories(${CMAKE_SOURCE_DIR}/replay)
include_directories(${CMAKE_SOURCE_DIR}/util)
if(WIN32)
@@ -41,8 +46,8 @@ set(dirs
${CMAKE_SOURCE_DIR}/logging
${CMAKE_SOURCE_DIR}/mapgen
${CMAKE_SOURCE_DIR}/model
${CMAKE_SOURCE_DIR}/replay
${CMAKE_SOURCE_DIR}/networking/common
${CMAKE_SOURCE_DIR}/replay
${CMAKE_SOURCE_DIR}/util
)
@@ -61,74 +66,64 @@ include_directories(${CMAKE_SOURCE_DIR})
set(HALITE_SOURCE_FILES "${SOURCE_FILES}" main.cpp)
set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/external)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_BINARY_DIR}/external)
include(ExternalProject)
ExternalProject_Add(nlohmann
URL https://github.com/nlohmann/json/releases/download/v3.1.2/include.zip
URL_HASH SHA256=495362ee1b9d03d9526ba9ccf1b4a9c37691abe3a642ddbced13e5778c16660c
PREFIX ${EXTERNAL_INSTALL_LOCATION}
SOURCE_DIR ${EXTERNAL_INSTALL_LOCATION}/nlohmann
CMAKE_COMMAND ""
BUILD_COMMAND ""
CONFIGURE_COMMAND ""
UPDATE_COMMAND ""
INSTALL_COMMAND ""
)
ExternalProject_Add(tclap
URL https://netix.dl.sourceforge.net/project/tclap/tclap-1.2.2.tar.gz
URL_HASH SHA256=f5013be7fcaafc69ba0ce2d1710f693f61e9c336b6292ae4f57554f59fde5837
PREFIX ${EXTERNAL_INSTALL_LOCATION}
SOURCE_DIR ${EXTERNAL_INSTALL_LOCATION}/tclap
CMAKE_COMMAND ""
BUILD_COMMAND ""
CONFIGURE_COMMAND ""
UPDATE_COMMAND ""
INSTALL_COMMAND ""
)
ExternalProject_Add(libzstd
URL https://github.com/facebook/zstd/archive/v1.3.4.zip
URL_HASH SHA256=76f3e6cadd9e1714cad7b550e53b82d4a5a5f9e08fbc0b3eb54abd0d0ebeb42d
PREFIX ${EXTERNAL_INSTALL_LOCATION}
CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX:PATH=${EXTERNAL_INSTALL_LOCATION} ${EXTERNAL_INSTALL_LOCATION}/src/libzstd/build/cmake/
)
configure_file(CMakeLists.txt.in deps-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -Wno-dev .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/deps-download)
if(result)
message(FATAL_ERROR "CMake step for dependencies failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/deps-download)
if(result)
message(FATAL_ERROR "Build step for dependencies failed: ${result}")
endif()
include_directories(${EXTERNAL_INSTALL_LOCATION}/include ${EXTERNAL_INSTALL_LOCATION}/nlohmann ${EXTERNAL_INSTALL_LOCATION}/tclap/include)
link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
add_subdirectory(${EXTERNAL_INSTALL_LOCATION}/zstd/build/cmake EXCLUDE_FROM_ALL)
add_subdirectory(${EXTERNAL_INSTALL_LOCATION}/catch)
add_executable(halite ${HALITE_SOURCE_FILES})
include_directories(${EXTERNAL_INSTALL_LOCATION}/zstd/lib ${EXTERNAL_INSTALL_LOCATION}/nlohmann ${EXTERNAL_INSTALL_LOCATION}/tclap/include)
link_directories(${EXTERNAL_INSTALL_LOCATION}/zstd/build/cmake/lib)
if (APPLE)
add_custom_target(
remove_dylib
${CMAKE_COMMAND} -E remove ${EXTERNAL_INSTALL_LOCATION}/lib/libzstd.1.3.4.dylib ${EXTERNAL_INSTALL_LOCATION}/lib/libzstd.dylib
)
else()
add_custom_target(
remove_dylib
${CMAKE_COMMAND} -E remove ${EXTERNAL_INSTALL_LOCATION}/lib/libzstd.1.3.4.so ${EXTERNAL_INSTALL_LOCATION}/lib/libzstd.so
)
endif()
add_library(halite_core OBJECT ${SOURCE_FILES})
add_dependencies(remove_dylib libzstd)
add_dependencies(halite remove_dylib)
add_executable(halite $<TARGET_OBJECTS:halite_core> main.cpp)
add_dependencies(halite VERSION_CHECK libzstd_static)
add_dependencies(halite VERSION_CHECK nlohmann tclap libzstd)
file(GLOB_RECURSE TEST_FILES ${CMAKE_SOURCE_DIR}/test/*.[ch]*)
add_executable(halite_test $<TARGET_OBJECTS:halite_core> ${TEST_FILES} ${CMAKE_SOURCE_DIR}/test/TestMain.cpp)
set(TEST_FILES ${SOURCE_FILES})
file(GLOB_RECURSE SOURCE ${CMAKE_SOURCE_DIR}/test/*.[ch]*)
set(TEST_FILES "${TEST_FILES}" ${SOURCE})
add_executable(halite_test ${TEST_FILES} ${CMAKE_SOURCE_DIR}/test/TestMain.cpp)
add_dependencies(halite_test nlohmann tclap libzstd)
add_dependencies(halite_test libzstd_static)
if (APPLE)
# No static linkage here - https://stackoverflow.com/questions/5259249/creating-static-mac-os-x-c-build
target_link_libraries(halite pthread zstd)
target_link_libraries(halite_test pthread zstd)
target_link_libraries(halite pthread libzstd_static)
target_link_libraries(halite_test pthread libzstd_static Catch2::Catch)
else()
# On Linux, make sure to link using the whole-archive option
# See: https://stackoverflow.com/questions/35116327
target_link_libraries(halite -Wl,--whole-archive pthread -Wl,--no-whole-archive -static zstd -Wl,--no-whole-archive)
target_link_libraries(halite -Wl,--whole-archive pthread -Wl,--no-whole-archive -static libzstd_static)
target_link_libraries(halite_test -Wl,--whole-archive pthread -Wl,--whole-archive -static libzstd_static Catch2::Catch)
endif()
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules)
include(CodeCoverage)
APPEND_COVERAGE_COMPILER_FLAGS()
set(COVERAGE_EXCLUDES '${CMAKE_SOURCE_DIR}/external/*' '${CMAKE_SOURCE_DIR}/test/*' '/usr/include/*')
if(APPLE)
set(COVERAGE_EXCLUDES ${COVERAGE_EXCLUDES} '/Applications/Xcode.app/*')
endif()
setup_target_for_coverage(NAME coverage EXECUTABLE halite_test)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${EXTERNAL_INSTALL_LOCATION}/catch/contrib)
include(Catch)
enable_testing()
catch_discover_tests(halite_test)
@@ -0,0 +1,52 @@
cmake_minimum_required(VERSION 2.8.2)
project(deps-download NONE)
set(EXTERNAL_INSTALL_LOCATION ${CMAKE_BINARY_DIR}/external)
include(ExternalProject)
ExternalProject_Add(catch-download
URL https://github.com/catchorg/Catch2/archive/v2.2.3.zip
URL_HASH SHA256=659679a47edb72f0bdc535770368d5fac4abd115f02376e3c5990fdd6fac4629
PREFIX ${EXTERNAL_INSTALL_LOCATION}
SOURCE_DIR ${EXTERNAL_INSTALL_LOCATION}/catch
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)
ExternalProject_Add(nlohmann-download
URL https://github.com/nlohmann/json/releases/download/v3.1.2/include.zip
URL_HASH SHA256=495362ee1b9d03d9526ba9ccf1b4a9c37691abe3a642ddbced13e5778c16660c
PREFIX ${EXTERNAL_INSTALL_LOCATION}
SOURCE_DIR ${EXTERNAL_INSTALL_LOCATION}/nlohmann
CMAKE_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
UPDATE_COMMAND ""
INSTALL_COMMAND ""
)
ExternalProject_Add(tclap-download
URL https://netix.dl.sourceforge.net/project/tclap/tclap-1.2.2.tar.gz
URL_HASH SHA256=f5013be7fcaafc69ba0ce2d1710f693f61e9c336b6292ae4f57554f59fde5837
PREFIX ${EXTERNAL_INSTALL_LOCATION}
SOURCE_DIR ${EXTERNAL_INSTALL_LOCATION}/tclap
CMAKE_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
UPDATE_COMMAND ""
INSTALL_COMMAND ""
)
ExternalProject_Add(zstd-download
URL https://github.com/facebook/zstd/archive/v1.3.4.zip
URL_HASH SHA256=76f3e6cadd9e1714cad7b550e53b82d4a5a5f9e08fbc0b3eb54abd0d0ebeb42d
PREFIX ${EXTERNAL_INSTALL_LOCATION}
SOURCE_DIR ${EXTERNAL_INSTALL_LOCATION}/zstd
CONFIGURE_COMMAND ${CMAKE_COMMAND} ${EXTERNAL_INSTALL_LOCATION}/zstd/build/cmake/
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
)
@@ -1,2 +1,2 @@
#define CATCH_CONFIG_MAIN
#include "test/catch.hpp"
#include "catch.hpp"
Oops, something went wrong.

0 comments on commit bb6f5d1

Please sign in to comment.