Something went wrong on our end
-
Studer Gabriel authoredStuder Gabriel authored
CMakeLists.txt 5.79 KiB
#-------------------------------------------------------------------------------
# Author: Bienchen
#-------------------------------------------------------------------------------
# Options to CMake:
# DISABLE_DOCUMENTATION: Don't build documentation, don't search for Sphinx
# DISABLE_DOCTEST: Don't run example code from documentation on 'make check'
# DISABLE_LINKCHECK: Don't test links from documentation on 'make check'
# (if documentation is disabled, there is no doctest, linkcheck at all)
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
# Set CMake policies
# Behaviour of target_link_libraries, always link by full path. CMP0060 can
# disable this to stay compatible with old projects. We want the new behaviour
# since before we needed to provide the full path ourselves, that is: we
# manually forced CMake to the new scheme.
cmake_policy(SET CMP0060 NEW)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake_support)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
project(ProMod3 CXX C)
include(PROMOD3)
# versioning info
set(PROMOD3_VERSION_MAJOR 3)
set(PROMOD3_VERSION_MINOR 2)
set(PROMOD3_VERSION_PATCH 0)
set(PROMOD3_VERSION_STRING ${PROMOD3_VERSION_MAJOR}.${PROMOD3_VERSION_MINOR})
set(PROMOD3_VERSION_STRING ${PROMOD3_VERSION_STRING}.${PROMOD3_VERSION_PATCH})
option(DISABLE_DOCUMENTATION "Do not build documentation" OFF)
option(DISABLE_DOCTEST "Do not check examples in documentation" OFF)
option(DISABLE_LINKCHECK "Do not check links in the documentation" OFF)
# get git info: current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# get git info: latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# set PM3_RUNTIME_PROFILING_LEVEL
if(NOT PM3_RUNTIME_PROFILING_LEVEL)
set(PM3_RUNTIME_PROFILING_LEVEL 0)
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
exec_program(gcc ARGS --version OUTPUT_VARIABLE CMAKE_C_COMPILER_VERSION)
if(CMAKE_C_COMPILER_VERSION MATCHES ".*4\\.[5-9].*")
set(PROMOD_GCC_45 true)
else()
set(PROMOD_GCC_45 false)
endif()
endif()
if(OPTIMIZE)
set(CMAKE_BUILD_TYPE Release)
set(_OPT ON)
else()
set(CMAKE_BUILD_TYPE Debug)
set(_OPT OFF)
endif()
if(ENABLE_SSE)
set(_ENABLE_SSE 1)
else()
set(_ENABLE_SSE 0)
endif()
setup_stage()
file(MAKE_DIRECTORY ${STAGE_DIR}
${EXECUTABLE_OUTPUT_PATH}
${HEADER_STAGE_PATH}
${LIB_STAGE_PATH}
${LIBEXEC_STAGE_PATH})
setup_compiler_flags()
# Python needed before Boost
find_package(Python 3.6 REQUIRED COMPONENTS Interpreter Development)
# Split version string
string(REPLACE "." ";" _python_version_list ${Python_VERSION})
list(GET _python_version_list 0 Python_VERSION_MAJOR)
list(GET _python_version_list 1 Python_VERSION_MINOR)
# where Python modules live
set(PYTHON_MODULE_PATH "python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages/")
setup_boost()
if(NOT DISABLE_DOCUMENTATION)
find_package(Sphinx REQUIRED)
set(PYTHON_DOC_URL "https://docs.python.org/${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}")
# this URL should always point to the latest version of OST
set(OST_DOC_URL "https://www.openstructure.org/docs")
endif()
find_package(OPENSTRUCTURE 2.2.0 REQUIRED
COMPONENTS io mol seq seq_alg mol_alg conop img mol_mm)
if(CMAKE_COMPILER_IS_GNUCXX)
# do not write back into cache, otherwise the compile command line gets
# expanded with multiple -fno-strict-aliasing flags, triggering a complete
# rebuild whenever cmake is run
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-strict-aliasing")
if("${CMAKE_CXX_COMPILER_VERSION}" VERSION_GREATER "4.6")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes")
endif("${CMAKE_CXX_COMPILER_VERSION}" VERSION_GREATER "4.6")
endif()
# additional packages/ headers/ etc.
# Eigen3 is mandatory right now but may vanish once OST switches to the same
# version.
find_package(Eigen3 3.3.0 REQUIRED)
if(NOT EIGEN3_FOUND)
message(FATAL_ERROR "Eigen3 is essential for building ${PROJECT_NAME}.")
endif()
# This is somewhat experimental: Checking if Boost is compiled with the same
# Python version used for Promod3. The very same macro is disabled in OST so
# it may fail at some point.
#promod3_match_boost_python_version(${Python_LIBRARIES})
# basic environment
include_directories(${Boost_INCLUDE_DIRS}
${OST_INCLUDE_DIR}
${EIGEN3_INCLUDE_DIR})
set(FILES_TO_BE_REMOVED ${PROJECT_BINARY_DIR}/stage)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
"${FILES_TO_BE_REMOVED}")
## sub dirs to be recognised by CMake
## e.g. add_subdirectory(src), subdirs have their own CMakeLists.txt
add_subdirectory(config)
add_subdirectory(core)
add_subdirectory(loop)
add_subdirectory(scoring)
add_subdirectory(sidechain)
add_subdirectory(modelling)
add_subdirectory(scripts)
add_subdirectory(actions)
add_subdirectory(extras)
add_subdirectory(cmake_support)
if(NOT DISABLE_DOCUMENTATION)
add_changelog_to_doc(FILE "${CMAKE_CURRENT_SOURCE_DIR}/CHANGELOG")
add_license_to_doc(FILE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
add_subdirectory(doc)
endif()
STRING(REGEX REPLACE "^\\\\+\"" "" occp ${OST_COMPOUNDS_CHEMLIB_PATH})
STRING(REGEX REPLACE "\\\\+\"$" "" occp ${occp})
## report setup
message(STATUS "${PROJECT_NAME} will be built with the following options:\n"
" OpenStructure (-DOST_ROOT) : ${OST_ROOT}\n"
" Compound library (-DCOMPOUND_LIB): ${occp}\n"
" Optimized (-DOPTIMIZE) : ${_OPT}\n"
" Python : ${Python_EXECUTABLE}\n"
" Eigen3 : ${EIGEN3_INCLUDE_DIR}\n")