2016-04-15 16:20:31 +03:00
|
|
|
cmake_minimum_required(VERSION 3.5.1)
|
2016-10-04 13:45:15 +03:00
|
|
|
|
2017-07-20 20:18:26 +03:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
2016-04-14 14:44:55 +03:00
|
|
|
|
2017-03-23 21:19:01 +03:00
|
|
|
project(amunmt C CXX)
|
|
|
|
|
2017-07-20 20:18:26 +03:00
|
|
|
set(CMAKE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
2017-03-23 21:19:01 +03:00
|
|
|
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
|
|
|
|
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
|
2016-10-04 13:45:15 +03:00
|
|
|
|
2017-11-07 13:21:36 +03:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-std=c++14 -fPIC -O3 -Ofast -m64 -march=native -funroll-loops -ffinite-math-only -Wno-unused-result -Wno-deprecated -pthread -DNDEBUG")
|
2017-03-14 14:58:12 +03:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-std=c++14 -fPIC -g -O0 -m64 -march=native -funroll-loops -ffinite-math-only -Wno-unused-result -Wno-deprecated -pthread")
|
2016-10-11 17:03:05 +03:00
|
|
|
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE} -g -pg")
|
2016-10-11 02:05:40 +03:00
|
|
|
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_RELEASE})
|
2016-04-14 14:44:55 +03:00
|
|
|
|
2016-11-30 13:36:02 +03:00
|
|
|
if(BUILD_STATIC)
|
|
|
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "-static")
|
|
|
|
set(Boost_USE_STATIC_LIBS "TRUE")
|
|
|
|
endif(BUILD_STATIC)
|
|
|
|
|
2016-05-15 13:21:11 +03:00
|
|
|
include_directories(${amunmt_SOURCE_DIR})
|
2016-09-27 16:55:57 +03:00
|
|
|
|
2017-03-17 16:22:42 +03:00
|
|
|
option(CPU "Select to compile with CPU support" ON)
|
2016-10-10 16:15:54 +03:00
|
|
|
option(CUDA "Select to compile CUDA support by default if available" ON)
|
2017-06-13 05:25:48 +03:00
|
|
|
option(FPGA "Select to compile with FPGA support" OFF)
|
2017-11-24 21:12:50 +03:00
|
|
|
option(MARIAN "Select to compile with Marian library" ON)
|
|
|
|
option(MARIAN_LIBRARY_ONLY "Automatically set when building amunmt. Don't touch this." ON)
|
2016-10-04 13:45:15 +03:00
|
|
|
|
2017-03-14 14:58:12 +03:00
|
|
|
if(CPU)
|
|
|
|
add_definitions(-DHAS_CPU)
|
|
|
|
endif(CPU)
|
|
|
|
|
2017-03-17 16:22:42 +03:00
|
|
|
if(FPGA)
|
|
|
|
add_definitions(-DHAS_FPGA)
|
2017-05-02 18:15:28 +03:00
|
|
|
endif(FPGA)
|
2017-03-22 04:51:41 +03:00
|
|
|
|
2016-10-10 16:15:54 +03:00
|
|
|
if(CUDA)
|
|
|
|
find_package(CUDA)
|
|
|
|
if(CUDA_FOUND)
|
2017-11-24 20:13:09 +03:00
|
|
|
LIST(APPEND CUDA_NVCC_FLAGS --default-stream per-thread; -std=c++11; -O3; -arch=sm_30; -gencode=arch=compute_30,code=sm_30; -gencode=arch=compute_50,code=sm_50; -gencode=arch=compute_52,code=sm_52; -gencode=arch=compute_60,code=sm_60; -gencode=arch=compute_61,code=sm_61; -gencode=arch=compute_61,code=compute_61 ; -lineinfo; --use_fast_math; -DNDEBUG;)
|
2016-11-01 21:06:33 +03:00
|
|
|
# add_definitions(-DCUDA_API_PER_THREAD_DEFAULT_STREAM)
|
2016-10-05 13:23:59 +03:00
|
|
|
add_definitions(-DCUDA)
|
2016-09-27 16:55:57 +03:00
|
|
|
SET(CUDA_PROPAGATE_HOST_FLAGS OFF)
|
2016-10-10 16:15:54 +03:00
|
|
|
message("-- Compiling with CUDA support")
|
2017-03-23 21:19:01 +03:00
|
|
|
|
|
|
|
if (MARIAN)
|
2017-03-30 02:04:02 +03:00
|
|
|
execute_process(COMMAND git submodule update --init --recursive --remote --no-fetch
|
2017-03-23 21:19:01 +03:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
endif(MARIAN)
|
|
|
|
|
2016-10-10 16:15:54 +03:00
|
|
|
else(CUDA_FOUND)
|
|
|
|
add_definitions(-DNO_CUDA)
|
|
|
|
message("-- Cannot find CUDA libraries. Compiling without them." )
|
|
|
|
endif(CUDA_FOUND)
|
|
|
|
else(CUDA)
|
|
|
|
message("-- Forcing compilation without CUDA.")
|
2016-09-27 16:54:05 +03:00
|
|
|
add_definitions(-DNO_CUDA)
|
2016-10-10 16:15:54 +03:00
|
|
|
endif(CUDA)
|
2016-04-14 14:44:55 +03:00
|
|
|
|
2017-08-01 12:41:52 +03:00
|
|
|
if(PYTHON_VERSION)
|
|
|
|
STRING(REPLACE "." "" PYTHON_VERSION_NORMALIZED ${PYTHON_VERSION})
|
|
|
|
else(PYTHON_VERSION)
|
|
|
|
set(PYTHON_VERSION "2.7")
|
|
|
|
endif(PYTHON_VERSION)
|
|
|
|
|
|
|
|
if (UNIX AND NOT APPLE)
|
|
|
|
|
|
|
|
if(PYTHON_VERSION_NORMALIZED)
|
|
|
|
set(BOOST_PYTHON_VERSION_NAME "python-py${PYTHON_VERSION_NORMALIZED}")
|
|
|
|
else(PYTHON_VERSION_NORMALIZED)
|
|
|
|
set(BOOST_PYTHON_VERSION_NAME "python")
|
|
|
|
endif(PYTHON_VERSION_NORMALIZED)
|
|
|
|
|
2017-09-21 22:38:14 +03:00
|
|
|
find_package(Boost COMPONENTS system filesystem program_options timer iostreams ${BOOST_PYTHON_VERSION_NAME} thread chrono)
|
2017-08-01 12:41:52 +03:00
|
|
|
elseif (APPLE)
|
|
|
|
|
|
|
|
# On macOS, boost-python component is named python if compiled against python2.7 or
|
|
|
|
# python3 if compiled against python3.x
|
|
|
|
if(NOT PYTHON_VERSION_NORMALIZED EQUAL 27)
|
|
|
|
set(BOOST_PYTHON_VERSION_NAME "python${PYTHON_VERSION_NORMALIZED}")
|
|
|
|
else(NOT PYTHON_VERSION_NORMALIZED EQUAL 27)
|
|
|
|
set(BOOST_PYTHON_VERSION_NAME "python")
|
|
|
|
endif(NOT PYTHON_VERSION_NORMALIZED EQUAL 27)
|
|
|
|
|
2017-09-21 22:38:14 +03:00
|
|
|
find_package(Boost COMPONENTS system filesystem program_options timer iostreams ${BOOST_PYTHON_VERSION_NAME} thread chrono)
|
2017-08-01 12:41:52 +03:00
|
|
|
endif (UNIX AND NOT APPLE)
|
|
|
|
|
2016-04-14 14:44:55 +03:00
|
|
|
if(Boost_FOUND)
|
|
|
|
include_directories(${Boost_INCLUDE_DIRS})
|
|
|
|
set(EXT_LIBS ${EXT_LIBS} ${Boost_LIBRARIES})
|
|
|
|
else(Boost_FOUND)
|
|
|
|
message(SEND_ERROR "Cannot find Boost libraries. Terminating." )
|
|
|
|
endif(Boost_FOUND)
|
|
|
|
|
2017-06-21 22:35:22 +03:00
|
|
|
if (FPGA)
|
|
|
|
find_package( OpenCL REQUIRED )
|
|
|
|
if(OpenCL_FOUND)
|
2017-03-17 18:22:27 +03:00
|
|
|
set(EXT_LIBS ${EXT_LIBS} ${OpenCL_LIBRARIES})
|
2017-06-21 22:35:22 +03:00
|
|
|
endif(OpenCL_FOUND)
|
|
|
|
endif(FPGA)
|
2017-03-17 18:22:27 +03:00
|
|
|
|
2017-08-01 12:41:52 +03:00
|
|
|
find_package(PythonLibs ${PYTHON_VERSION} REQUIRED)
|
2016-10-04 13:45:15 +03:00
|
|
|
if(PYTHONLIBS_FOUND)
|
2016-10-31 17:59:09 +03:00
|
|
|
message("-- Found Python" )
|
|
|
|
include_directories(${PYTHON_INCLUDE_DIRS})
|
|
|
|
set(EXT_LIBS ${EXT_LIBS} ${PYTHON_LIBRARIES})
|
2016-10-04 13:45:15 +03:00
|
|
|
else(PYTHONLIBS_FOUND)
|
2016-11-30 13:36:02 +03:00
|
|
|
message("-- Cannot find python libraries. Building without bindings." )
|
2016-10-04 13:45:15 +03:00
|
|
|
endif(PYTHONLIBS_FOUND)
|
|
|
|
|
2016-04-16 17:44:03 +03:00
|
|
|
find_package (ZLIB)
|
|
|
|
if (ZLIB_FOUND)
|
|
|
|
include_directories(${ZLIB_INCLUDE_DIRS})
|
|
|
|
set(EXT_LIBS ${EXT_LIBS} ${ZLIB_LIBRARIES})
|
|
|
|
endif (ZLIB_FOUND)
|
|
|
|
|
2016-10-31 17:59:09 +03:00
|
|
|
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
|
|
|
|
FIND_PACKAGE(Git)
|
|
|
|
IF(GIT_FOUND)
|
|
|
|
EXECUTE_PROCESS(
|
2017-03-23 21:19:01 +03:00
|
|
|
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
|
|
|
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
OUTPUT_VARIABLE "AMUNMT_BUILD_VERSION"
|
|
|
|
ERROR_QUIET
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2016-10-31 17:59:09 +03:00
|
|
|
MESSAGE( STATUS "Git version: ${AMUNMT_BUILD_VERSION}" )
|
|
|
|
ELSE(GIT_FOUND)
|
|
|
|
SET(AMUNMT_BUILD_VERSION 0)
|
|
|
|
ENDIF(GIT_FOUND)
|
|
|
|
ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
|
2016-11-10 16:04:53 +03:00
|
|
|
SET(GIT_SHA1 ${AMUNMT_BUILD_VERSION})
|
2016-10-31 17:59:09 +03:00
|
|
|
|
|
|
|
include_directories(${amunmt_SOURCE_DIR}/src)
|
2016-04-14 14:44:55 +03:00
|
|
|
add_subdirectory(src)
|