101 lines
3.5 KiB
CMake
101 lines
3.5 KiB
CMake
cmake_minimum_required(VERSION 3.0)
|
|
project(ReducedModelOptimization)
|
|
#message(STATUS "The compiler ${CMAKE_CXX_COMPILER}")
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
#Add the project cmake scripts to the module path
|
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
|
|
|
#Download external dependencies NOTE: If the user has one of these libs it shouldn't be downloaded again.
|
|
include(${CMAKE_MODULE_PATH}/DownloadProject.cmake)
|
|
#if (CMAKE_VERSION VERSION_LESS 3.2)
|
|
# set(UPDATE_DISCONNECTED_IF_AVAILABLE "")
|
|
#else()
|
|
# set(UPDATE_DISCONNECTED_IF_AVAILABLE "UPDATE_DISCONNECTED 1")
|
|
#endif()
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
|
|
set(EXTERNAL_DEPS_DIR "C:/Users/iason/Downloads/ReducedModelOptimization/build/externalDependencies/")
|
|
else()
|
|
set(EXTERNAL_DEPS_DIR "/home/iason/Coding/build/external dependencies/")
|
|
endif()
|
|
|
|
##Create directory for the external libraries
|
|
file(MAKE_DIRECTORY ${EXTERNAL_DEPS_DIR})
|
|
|
|
#Add the project sources
|
|
file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)
|
|
|
|
if(MSVC)
|
|
add_compile_definitions(_HAS_STD_BYTE=0)
|
|
endif(MSVC)
|
|
|
|
add_executable(${PROJECT_NAME} ${SOURCES})
|
|
|
|
if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
|
set(USE_POLYSCOPE false)
|
|
set(MYSOURCES_STATIC_LINK true)
|
|
set(USE_ENSMALLEN true)
|
|
else()
|
|
# set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
|
set(USE_POLYSCOPE true)
|
|
if(${USE_POLYSCOPE})
|
|
add_compile_definitions(POLYSCOPE_DEFINED)
|
|
endif()
|
|
set(MYSOURCES_STATIC_LINK false)
|
|
set(USE_ENSMALLEN true)
|
|
# if(NOT ${MYSOURCES_STATIC_LINK})
|
|
# set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
|
|
# set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" )
|
|
# endif()
|
|
endif()
|
|
if(${USE_ENSMALLEN})
|
|
add_compile_definitions(USE_ENSMALLEN)
|
|
endif()
|
|
|
|
#dlib
|
|
set(DLIB_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}/dlib)
|
|
download_project(PROJ DLIB
|
|
GIT_REPOSITORY https://github.com/davisking/dlib.git
|
|
GIT_TAG master
|
|
BINARY_DIR ${DLIB_BIN_DIR}
|
|
PREFIX ${EXTERNAL_DEPS_DIR}
|
|
${UPDATE_DISCONNECTED_IF_AVAILABLE}
|
|
)
|
|
add_subdirectory(${DLIB_SOURCE_DIR} ${DLIB_BIN_DIR})
|
|
if(${MYSOURCES_STATIC_LINK})
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC -static dlib::dlib)
|
|
else()
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC dlib::dlib)
|
|
endif()
|
|
add_compile_definitions(DLIB_DEFINED)
|
|
|
|
set(MYSOURCES_SOURCE_DIR "/home/iason/Coding/Libraries/MySources")
|
|
set(MYSOURCES_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR}/MySourcesBinDir)
|
|
if (EXISTS ${MYSOURCES_SOURCE_DIR})
|
|
else()
|
|
##MySources
|
|
download_project(PROJ MYSOURCES
|
|
GIT_REPOSITORY https://gitea-s2i2s.isti.cnr.it/manolas/MySources.git
|
|
GIT_TAG master
|
|
PREFIX ${EXTERNAL_DEPS_DIR}
|
|
BINARY_DIR ${MYSOURCES_BIN_DIR}
|
|
${UPDATE_DISCONNECTED_IF_AVAILABLE}
|
|
)
|
|
endif()
|
|
add_subdirectory(${MYSOURCES_SOURCE_DIR} ${MYSOURCES_BIN_DIR})
|
|
|
|
target_include_directories(${PROJECT_NAME}
|
|
PUBLIC ${MYSOURCES_SOURCE_DIR}
|
|
)
|
|
|
|
if(${MYSOURCES_STATIC_LINK})
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC #[[-static]] MySources)
|
|
else()
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC MySources)
|
|
endif()
|
|
|
|
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)
|