Skip to content
Snippets Groups Projects
CMakeLists.txt 3.50 KiB
cmake_minimum_required(VERSION 3.0)
project(lib4neuro)

message("Using CMake ${CMAKE_VERSION}")

#TODO request newer version of CMake >=3.12

#TODO rewrite to use add_compile_definitions
if(WIN32)
    add_compile_options("/D BOOST_ALL_NO_LIB")
    add_compile_options("/D NOMINMAX")
else()
	add_compile_options("-DBOOST_TEST_DYN_LINK")
endif()

#------------#
# Build type #
#------------#
# Release / None / Debug
if (NOT CMAKE_BUILD_TYPE)
    set (CMAKE_BUILD_TYPE RELEASE CACHE STRING
         "Choose the type of build, options are: None Debug Release."
         FORCE)
elseif("CMAKE_BUILD_TYPE" STREQUAL "Debug")
    #TODO rewrite to use add_compile_definitions
endif (NOT CMAKE_BUILD_TYPE)

#------------------------#
# Dependencies link type #
#------------------------#
if(NOT DEPENDENCIES_LINK_TYPE AND NOT ENV{DEPENDENCIES_LINK_TYPE})
    message(FATAL_ERROR "Please, set the variable DEPENDENCIES_LINK_TYPE to either 'static' or 'shared'!")
endif()

#--------------------------------#
# Setting C++ compiler flags #
#--------------------------------#
set(CMAKE_CXX_STANDARD 17)

#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )

if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" )
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost" )
elseif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" ) 
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0 /bigobj")
    add_compile_options("/D _SCL_SECURE_NO_WARNINGS")
    add_compile_options("/D_CRT_SECURE_NO_WARNINGS")
else()
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()

#--------------------#
# Automatic settings #
#--------------------#
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
  set(CMAKE_VERBOSE_MAKEFILE ON)
endif()

#-------------------------#
# Find external libraries #
#-------------------------#
message("Looking for external libraries...")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})

set(Boost_USE_MULTITHREADED ON)
set(Boost_DEBUG ON)

find_package(
    Boost