MySources/CMakeLists.txt

126 lines
5.8 KiB
CMake
Raw Normal View History

2021-12-19 19:15:36 +01:00
cmake_minimum_required(VERSION 2.8)
2021-03-15 17:57:43 +01:00
project(MySources)
2022-01-05 13:10:49 +01:00
file(GLOB MySourcesFiles ${CMAKE_CURRENT_LIST_DIR}/*.hpp ${CMAKE_CURRENT_LIST_DIR}/*.cpp)
add_library(${PROJECT_NAME} ${MySourcesFiles} )
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)
2021-03-15 17:57:43 +01:00
#Download external dependencies NOTE: If the user has one of these libs it shouldn't be downloaded again.
include(${CMAKE_CURRENT_LIST_DIR}/cmake/DownloadProject.cmake)
if (CMAKE_VERSION VERSION_LESS 3.2)
set(UPDATE_DISCONNECTED_IF_AVAILABLE "")
else()
set(UPDATE_DISCONNECTED_IF_AVAILABLE "UPDATE_DISCONNECTED 1")
endif()
2021-04-08 20:03:23 +02:00
set(EXTERNAL_DEPS_DIR "/home/iason/Coding/build/external dependencies")
if(NOT EXISTS ${EXTERNAL_DEPS_DIR})
set(EXTERNAL_DEPS_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
##Create directory for the external libraries
file(MAKE_DIRECTORY ${EXTERNAL_DEPS_DIR})
2021-11-15 10:08:39 +01:00
if(${USE_POLYSCOPE})
2021-12-23 14:51:23 +01:00
set(POLYSCOPE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/polyscope)
download_project(PROJ POLYSCOPE
GIT_REPOSITORY https://github.com/nmwsharp/polyscope.git
GIT_TAG master
PREFIX ${EXTERNAL_DEPS_DIR}
BINARY_DIR ${POLYSCOPE_BINARY_DIR}
${UPDATE_DISCONNECTED_IF_AVAILABLE}
)
add_subdirectory(${POLYSCOPE_SOURCE_DIR} ${POLYSCOPE_BINARY_DIR})
add_compile_definitions(POLYSCOPE_DEFINED)
2022-01-05 13:10:49 +01:00
target_sources(${PROJECT_NAME} PUBLIC ${POLYSCOPE_SOURCE_DIR}/deps/imgui/imgui/misc/cpp/imgui_stdlib.cpp)
2021-11-15 10:08:39 +01:00
endif()
2021-12-23 14:51:23 +01:00
2021-03-15 17:57:43 +01:00
##vcglib devel branch
download_project(PROJ vcglib_devel
2022-01-05 13:10:49 +01:00
GIT_REPOSITORY https://gitea-s2i2s.isti.cnr.it/manolas/vcglib.git
2021-03-15 17:57:43 +01:00
GIT_TAG devel
2021-04-08 20:03:23 +02:00
PREFIX ${EXTERNAL_DEPS_DIR}
2021-03-15 17:57:43 +01:00
${UPDATE_DISCONNECTED_IF_AVAILABLE}
)
2021-11-15 19:17:14 +01:00
add_subdirectory(${vcglib_devel_SOURCE_DIR} ${vcglib_devel_BINARY_DIR})
2022-01-05 13:10:49 +01:00
target_sources(${PROJECT_NAME} PUBLIC ${vcglib_devel_SOURCE_DIR}/wrap/ply/plylib.cpp)
2021-12-23 14:51:23 +01:00
2021-12-19 19:15:36 +01:00
##matplot++ lib
2021-12-23 14:51:23 +01:00
set(MATPLOTPLUSPLUS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/matplot)
2021-12-19 19:15:36 +01:00
download_project(PROJ MATPLOTPLUSPLUS
GIT_REPOSITORY https://github.com/alandefreitas/matplotplusplus
GIT_TAG master
2021-12-23 14:51:23 +01:00
BINARY_DIR ${MATPLOTPLUSPLUS_BINARY_DIR}
2021-12-19 19:15:36 +01:00
PREFIX ${EXTERNAL_DEPS_DIR}
${UPDATE_DISCONNECTED_IF_AVAILABLE}
)
add_subdirectory(${MATPLOTPLUSPLUS_SOURCE_DIR} ${MATPLOTPLUSPLUS_BINARY_DIR})
2021-12-23 14:51:23 +01:00
2021-04-08 20:03:23 +02:00
##threed-beam-fea
2021-12-23 14:51:23 +01:00
set(threed-beam-fea_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/threed-beam-fea)
2021-04-08 20:03:23 +02:00
download_project(PROJ threed-beam-fea
2022-01-19 15:09:38 +01:00
# GIT_REPOSITORY https://github.com/IasonManolas/threed-beam-fea.git
GIT_REPOSITORY https://gitea-s2i2s.isti.cnr.it/manolas/threed-beam-fea.git
2021-04-08 20:03:23 +02:00
GIT_TAG master
2021-12-23 14:51:23 +01:00
BINARY_DIR ${threed-beam-fea_BINARY_DIR}
2021-04-08 20:03:23 +02:00
PREFIX ${EXTERNAL_DEPS_DIR}
${UPDATE_DISCONNECTED_IF_AVAILABLE}
)
add_subdirectory(${threed-beam-fea_SOURCE_DIR} ${threed-beam-fea_BINARY_DIR})
2021-12-23 14:51:23 +01:00
2021-12-19 19:15:36 +01:00
##TBB
2021-12-23 14:51:23 +01:00
set(TBB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/tbb)
2021-12-19 19:15:36 +01:00
download_project(PROJ TBB
GIT_REPOSITORY https://github.com/wjakob/tbb.git
GIT_TAG master
PREFIX ${EXTERNAL_DEPS_DIR}
2021-12-23 14:51:23 +01:00
BINARY_DIR ${TBB_BINARY_DIR}
2021-12-19 19:15:36 +01:00
${UPDATE_DISCONNECTED_IF_AVAILABLE}
)
option(TBB_BUILD_TESTS "Build TBB tests and enable testing infrastructure" OFF)
add_subdirectory(${TBB_SOURCE_DIR} ${TBB_BINARY_DIR})
link_directories(${TBB_BINARY_DIR})
2021-03-15 17:57:43 +01:00
###Eigen 3 NOTE: Eigen is required on the system the code is ran
find_package(Eigen3 3.3 REQUIRED)
if(MSVC)
add_compile_definitions(_HAS_STD_BYTE=0)
endif(MSVC)
2021-03-15 17:57:43 +01:00
#link_directories(${CMAKE_CURRENT_LIST_DIR}/boost_graph/libs)
2022-01-05 13:10:49 +01:00
2021-12-19 19:15:36 +01:00
if(${MYSOURCES_STATIC_LINK})
message("Linking statically")
2022-01-05 13:10:49 +01:00
target_link_libraries(${PROJECT_NAME} PUBLIC -static Eigen3::Eigen matplot ThreedBeamFEA ${TBB_BINARY_DIR}/libtbb_static.a #[[tbb_static]] pthread gfortran quadmath)
2021-12-19 19:15:36 +01:00
else()
2022-01-05 13:10:49 +01:00
# set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen matplot ThreedBeamFEA tbb pthread)
2021-12-19 19:15:36 +01:00
if(${USE_POLYSCOPE})
2022-01-05 13:10:49 +01:00
message("Using polyscope")
target_link_libraries(${PROJECT_NAME} PUBLIC polyscope)
endif()
endif()
2021-12-19 19:15:36 +01:00
target_link_directories(MySources PUBLIC ${CMAKE_CURRENT_LIST_DIR}/boost_graph/libs)
2022-01-05 13:10:49 +01:00
target_include_directories(${PROJECT_NAME}
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/boost_graph
PUBLIC ${vcglib_devel_SOURCE_DIR}
PUBLIC ${threed-beam-fea_SOURCE_DIR}
2022-01-05 13:10:49 +01:00
PUBLIC matplot
)
if(USE_ENSMALLEN)
##ENSMALLEN
2021-12-23 14:51:23 +01:00
set(ENSMALLEN_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/ensmallen)
download_project(PROJ ENSMALLEN
GIT_REPOSITORY https://github.com/mlpack/ensmallen.git
GIT_TAG master
2021-12-23 14:51:23 +01:00
BINARY_DIR ${ENSMALLEN_BINARY_DIR}
PREFIX ${EXTERNAL_DEPS_DIR}
${UPDATE_DISCONNECTED_IF_AVAILABLE}
)
add_subdirectory(${ENSMALLEN_SOURCE_DIR} ${ENSMALLEN_BINARY_DIR})
set(ARMADILLO_SOURCE_DIR "/home/iason/Coding/Libraries/armadillo")
add_subdirectory(${ARMADILLO_SOURCE_DIR} ${EXTERNAL_DEPS_DIR}/armadillo_build)
if(${MYSOURCES_STATIC_LINK})
target_link_libraries(${PROJECT_NAME} PUBLIC "-static" ensmallen ${EXTERNAL_DEPS_DIR}/armadillo_build/libarmadillo.a)
else()
target_link_libraries(${PROJECT_NAME} PUBLIC armadillo ensmallen)
endif()
2022-01-05 13:10:49 +01:00
target_include_directories(${PROJECT_NAME} PUBLIC ${ARMADILLO_SOURCE_DIR}/include ${ENSMALLEN_SOURCE_DIR})
endif()