-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
2,998 additions
and
42 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,249 @@ | ||
cmake_minimum_required(VERSION 2.8.12) | ||
project(aat) | ||
set(CMAKE_CXX_STANDARD 14) | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules/" ${CMAKE_MODULE_PATH} ) | ||
find_package(Color) | ||
|
||
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") | ||
set(WIN32 ON) | ||
endif() | ||
|
||
############################## | ||
# helper to grab gtest et al # | ||
############################## | ||
function (build_dep name cmake_file) | ||
if(EXISTS ${CMAKE_BINARY_DIR}/${name}-build) | ||
message(WARNING "${Cyan}Dependency found - not rebuilding - ${CMAKE_BINARY_DIR}/${name}-build${ColorReset}") | ||
else() | ||
configure_file(${cmake_file} ${name}-download/CMakeLists.txt) | ||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . | ||
RESULT_VARIABLE result | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${name}-download ) | ||
if(result) | ||
message(FATAL_ERROR "CMake step for ${name} failed: ${result}") | ||
endif() | ||
execute_process(COMMAND ${CMAKE_COMMAND} --build . | ||
RESULT_VARIABLE result | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${name}-download ) | ||
if(result) | ||
message(FATAL_ERROR "Build step for ${name} failed: ${result}") | ||
endif() | ||
endif() | ||
add_subdirectory(${CMAKE_BINARY_DIR}/${name}-src | ||
${CMAKE_BINARY_DIR}/${name}-build | ||
EXCLUDE_FROM_ALL) | ||
|
||
include_directories(${CMAKE_BINARY_DIR}/${name}-src/extras/${name}/include) | ||
include_directories(${CMAKE_BINARY_DIR}/${name}-src/include) | ||
include_directories(${CMAKE_BINARY_DIR}/${name}-src) | ||
endfunction() | ||
############################## | ||
|
||
|
||
####################### | ||
# BUILD CONFIGURATION # | ||
####################### | ||
option(CMAKE_BUILD_TYPE "Release/Debug build" RELEASE) | ||
option(CPP_BUILD_TESTS "Build the C++ Tests" OFF) | ||
option(CPP_BUILD_STRICT "Build the C++ with strict warnings" OFF) | ||
|
||
if(DEFINED ENV{PSP_DEBUG}) | ||
set(CMAKE_BUILD_TYPE DEBUG) | ||
else() | ||
if (NOT DEFINED CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE RELEASE) | ||
endif() | ||
endif() | ||
|
||
if (NOT DEFINED CPP_BUILD_TESTS) | ||
set(CPP_BUILD_TESTS ON) | ||
endif() | ||
|
||
if (NOT DEFINED CPP_BUILD_STRICT) | ||
set(CPP_BUILD_STRICT OFF) | ||
endif() | ||
|
||
message(WARNING "${Cyan}Building C++ binding${ColorReset}") | ||
message(WARNING "${Cyan}Building Python binding${ColorReset}") | ||
|
||
if (CPP_BUILD_TESTS) | ||
message(WARNING "${Cyan}Building C++ tests${ColorReset}") | ||
else() | ||
message(WARNING "${Cyan}Skipping C++ tests${ColorReset}") | ||
endif() | ||
|
||
if (NOT CPP_BUILD_STRICT) | ||
message(WARNING "${Cyan}Building C++ without strict warnings${ColorReset}") | ||
else() | ||
message(WARNING "${Cyan}Building C++ with strict warnings${ColorReset}") | ||
endif() | ||
|
||
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER ) | ||
if(CMAKE_BUILD_TYPE_LOWER STREQUAL debug) | ||
message(WARNING "${Red}Building DEBUG${ColorReset}") | ||
add_definitions(-DDEBUG) | ||
else() | ||
message(WARNING "${Cyan}Building RELEASE${ColorReset}") | ||
endif() | ||
|
||
if(BUILD_DOCS) | ||
message(WARNING "${Cyan}Building Documentation${ColorReset}") | ||
else() | ||
message(WARNING "${Cyan}Skipping Documentation${ColorReset}") | ||
endif() | ||
####################### | ||
|
||
##################### | ||
# VANILLA CPP BUILD # | ||
##################### | ||
if(CMAKE_BUILD_TYPE_LOWER STREQUAL debug) | ||
set(OPT_FLAGS " \ | ||
-O1 \ | ||
-g3 \ | ||
") | ||
else() | ||
set(OPT_FLAGS " \ | ||
-O3 \ | ||
-g0 \ | ||
") | ||
endif() | ||
|
||
set(CMAKE_CXX_FLAGS " \ | ||
${CMAKE_CXX_FLAGS} \ | ||
${EXTENDED_FLAGS} \ | ||
${OPT_FLAGS} \ | ||
") | ||
|
||
|
||
find_package(Boost) | ||
if(NOT Boost_FOUND) | ||
message("${Red}Boost could not be located${ColorReset}") | ||
else() | ||
message("${Cyan}Found boost in ${Boost_INCLUDE_DIRS} ${Boost_LIBRARY_DIRS} ${ColorReset}") | ||
endif() | ||
include_directories( ${Boost_INCLUDE_DIRS} ) | ||
|
||
if(WIN32) | ||
foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996) | ||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd${warning}") | ||
endforeach(warning) | ||
else() | ||
include_directories("/usr/local/include") | ||
endif() | ||
|
||
|
||
######################### | ||
# PYTHON BINDINGS BUILD # | ||
######################### | ||
include_directories("/usr/local/include/python3.7m") # FIXME | ||
find_package( PythonInterp 3.7 REQUIRED ) | ||
find_package( PythonLibs 3.7 REQUIRED ) | ||
include_directories( ${PYTHON_INCLUDE_DIRS} ) | ||
find_package(NumPy) | ||
|
||
find_package( Boost COMPONENTS python REQUIRED ) | ||
find_library( BOOST_PYTHON boost_python) | ||
find_library( BOOST_NUMPY boost_numpy) | ||
include_directories( ${Boost_INCLUDE_DIR} ) | ||
|
||
include_directories( ${PYTHON_NUMPY_INCLUDE_DIR}) | ||
##################### | ||
|
||
if (WIN32) | ||
set(CMAKE_CXX_FLAGS " /EHsc") | ||
else() | ||
set(CMAKE_CXX_FLAGS " -std=c++0x ${CMAKE_CXX_FLAGS}") | ||
endif() | ||
|
||
|
||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") | ||
set(CMAKE_SHARED_LIBRARY_SUFFIX .so) | ||
endif() | ||
set(CMAKE_SHARED_LIBRARY_PREFIX "") | ||
|
||
|
||
include_directories("${CMAKE_SOURCE_DIR}/cpp/include") | ||
|
||
######################## | ||
# Python extra targets # | ||
######################## | ||
add_library(test SHARED | ||
${CMAKE_SOURCE_DIR}/cpp/src/test.cpp | ||
${HEADER_FILES}) | ||
set_target_properties(test PROPERTIES | ||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/aat) | ||
target_link_libraries(test ${BOOST_PYTHON}) | ||
target_link_libraries(test ${BOOST_NUMPY}) | ||
target_link_libraries(test ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) | ||
|
||
add_library(_cpp_helpers SHARED | ||
${CMAKE_SOURCE_DIR}/cpp/src/exchanges/_cpp_helpers.cpp) | ||
set_target_properties(_cpp_helpers PROPERTIES | ||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/aat/exchanges) | ||
target_link_libraries(_cpp_helpers test) | ||
target_link_libraries(_cpp_helpers ${BOOST_PYTHON}) | ||
target_link_libraries(_cpp_helpers ${BOOST_NUMPY}) | ||
target_link_libraries(_cpp_helpers ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) | ||
######################## | ||
|
||
if(CPP_BUILD_STRICT AND NOT WIN32) | ||
target_compile_options(test PRIVATE -Wall -Werror) | ||
target_compile_options(test PRIVATE $<$<CONFIG:DEBUG>:-fPIC -O0>) | ||
target_compile_options(_cpp_helpers PRIVATE -Wall -Werror) | ||
target_compile_options(_cpp_helpers PRIVATE $<$<CONFIG:DEBUG>:-fPIC -O0>) | ||
endif() | ||
|
||
|
||
############# | ||
# CPP TESTS # | ||
############# | ||
if (CPP_BUILD_TESTS) | ||
if (WIN32) | ||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) | ||
endif() | ||
build_dep("googletest" "cmake/GTest.txt.in") | ||
|
||
add_subdirectory(cpp/tests) | ||
add_custom_target(gcov | ||
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/coverage | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
) | ||
add_custom_command(TARGET gcov | ||
COMMAND echo "=================== GCOV ====================" | ||
COMMAND gcovr -r ../ --html --html-details -o coverage/index.html | ||
COMMAND xdg-open coverage/index.html | ||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | ||
) | ||
endif() | ||
############# | ||
|
||
######## | ||
# Docs # | ||
######## | ||
if(BUILD_DOCS) | ||
add_custom_target(doxygen) | ||
add_custom_command(TARGET doxygen | ||
COMMAND doxygen doxygen.conf | ||
WORKING_DIRECTORY docs | ||
COMMENT "Build doxygen xml files used by sphinx/breathe." | ||
) | ||
|
||
add_custom_target(docs-html ALL) | ||
add_custom_command(TARGET docs-html | ||
COMMAND sphinx-build -b html . build/html | ||
WORKING_DIRECTORY docs | ||
COMMENT "Build html documentation" | ||
) | ||
add_dependencies(docs-html doxygen) | ||
|
||
# add_custom_target(docs-markdown ALL) | ||
# add_custom_command(TARGET docs-html | ||
# COMMAND sphinx-build -M markdown . build/ | ||
# WORKING_DIRECTORY ../../docs | ||
# COMMENT "Build markdown documentation" | ||
# ) | ||
# add_dependencies(docs-html doxygen) | ||
|
||
endif() | ||
########## |
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,16 @@ | ||
cmake_minimum_required(VERSION 2.8.2) | ||
|
||
project(googletest-download NONE) | ||
|
||
include(ExternalProject) | ||
ExternalProject_Add(googletest | ||
GIT_REPOSITORY https://github.com/google/googletest.git | ||
GIT_TAG master | ||
SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" | ||
BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" | ||
CONFIGURE_COMMAND "" | ||
BUILD_COMMAND "" | ||
INSTALL_COMMAND "" | ||
TEST_COMMAND "" | ||
CMAKE_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" | ||
) |
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,11 @@ | ||
if(NOT WIN32) | ||
string(ASCII 27 Esc) | ||
set(ColorReset "${Esc}[m") | ||
set(Red "${Esc}[1;31m") | ||
set(Green "${Esc}[1;32m") | ||
set(Yellow "${Esc}[1;33m") | ||
set(Blue "${Esc}[1;34m") | ||
set(Magenta "${Esc}[1;35m") | ||
set(Cyan "${Esc}[1;36m") | ||
set(White "${Esc}[1;37m") | ||
endif() |
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,41 @@ | ||
# Find the Python NumPy package | ||
# PYTHON_NUMPY_INCLUDE_DIR | ||
# PYTHON_NUMPY_FOUND | ||
# will be set by this script | ||
|
||
cmake_minimum_required(VERSION 2.6) | ||
|
||
if(NOT PYTHON_EXECUTABLE) | ||
if(NumPy_FIND_QUIETLY) | ||
find_package(PythonInterp QUIET) | ||
else() | ||
find_package(PythonInterp) | ||
set(__numpy_out 1) | ||
endif() | ||
endif() | ||
|
||
if (PYTHON_EXECUTABLE) | ||
# Find out the include path | ||
execute_process( | ||
COMMAND "${PYTHON_EXECUTABLE}" -c | ||
"from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept:pass\n" | ||
OUTPUT_VARIABLE __numpy_path) | ||
# And the version | ||
execute_process( | ||
COMMAND "${PYTHON_EXECUTABLE}" -c | ||
"from __future__ import print_function\ntry: import numpy; print(numpy.__version__, end='')\nexcept:pass\n" | ||
OUTPUT_VARIABLE __numpy_version) | ||
elseif(__numpy_out) | ||
message(STATUS "Python executable not found.") | ||
endif(PYTHON_EXECUTABLE) | ||
|
||
find_path(PYTHON_NUMPY_INCLUDE_DIR numpy/arrayobject.h | ||
HINTS "${__numpy_path}" "${PYTHON_INCLUDE_PATH}" NO_DEFAULT_PATH) | ||
|
||
if(PYTHON_NUMPY_INCLUDE_DIR) | ||
set(PYTHON_NUMPY_FOUND 1 CACHE INTERNAL "Python numpy found") | ||
endif(PYTHON_NUMPY_INCLUDE_DIR) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(NumPy REQUIRED_VARS PYTHON_NUMPY_INCLUDE_DIR | ||
VERSION_VAR __numpy_version) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.