127 lines
5.8 KiB
CMake
Executable File
127 lines
5.8 KiB
CMake
Executable File
cmake_minimum_required(VERSION 2.8)
|
|
project(MySources)
|
|
|
|
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)
|
|
|
|
#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()
|
|
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})
|
|
if(${USE_POLYSCOPE})
|
|
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)
|
|
target_sources(${PROJECT_NAME} PUBLIC ${POLYSCOPE_SOURCE_DIR}/deps/imgui/imgui/misc/cpp/imgui_stdlib.cpp)
|
|
endif()
|
|
|
|
##vcglib devel branch
|
|
download_project(PROJ vcglib_devel
|
|
GIT_REPOSITORY https://gitea-s2i2s.isti.cnr.it/manolas/vcglib.git
|
|
GIT_TAG devel
|
|
PREFIX ${EXTERNAL_DEPS_DIR}
|
|
${UPDATE_DISCONNECTED_IF_AVAILABLE}
|
|
)
|
|
add_subdirectory(${vcglib_devel_SOURCE_DIR} ${vcglib_devel_BINARY_DIR})
|
|
target_sources(${PROJECT_NAME} PUBLIC ${vcglib_devel_SOURCE_DIR}/wrap/ply/plylib.cpp)
|
|
|
|
##matplot++ lib
|
|
set(MATPLOTPLUSPLUS_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/matplot)
|
|
download_project(PROJ MATPLOTPLUSPLUS
|
|
GIT_REPOSITORY https://github.com/alandefreitas/matplotplusplus
|
|
GIT_TAG master
|
|
BINARY_DIR ${MATPLOTPLUSPLUS_BINARY_DIR}
|
|
PREFIX ${EXTERNAL_DEPS_DIR}
|
|
${UPDATE_DISCONNECTED_IF_AVAILABLE}
|
|
)
|
|
add_subdirectory(${MATPLOTPLUSPLUS_SOURCE_DIR} ${MATPLOTPLUSPLUS_BINARY_DIR})
|
|
|
|
##threed-beam-fea
|
|
set(threed-beam-fea_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/threed-beam-fea)
|
|
download_project(PROJ threed-beam-fea
|
|
# GIT_REPOSITORY https://github.com/IasonManolas/threed-beam-fea.git
|
|
GIT_REPOSITORY https://gitea-s2i2s.isti.cnr.it/manolas/threed-beam-fea.git
|
|
GIT_TAG master
|
|
BINARY_DIR ${threed-beam-fea_BINARY_DIR}
|
|
PREFIX ${EXTERNAL_DEPS_DIR}
|
|
${UPDATE_DISCONNECTED_IF_AVAILABLE}
|
|
)
|
|
add_subdirectory(${threed-beam-fea_SOURCE_DIR} ${threed-beam-fea_BINARY_DIR})
|
|
|
|
##TBB
|
|
set(TBB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/tbb)
|
|
download_project(PROJ TBB
|
|
GIT_REPOSITORY https://github.com/wjakob/tbb.git
|
|
GIT_TAG master
|
|
PREFIX ${EXTERNAL_DEPS_DIR}
|
|
BINARY_DIR ${TBB_BINARY_DIR}
|
|
${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})
|
|
###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)
|
|
#link_directories(${CMAKE_CURRENT_LIST_DIR}/boost_graph/libs)
|
|
|
|
if(${MYSOURCES_STATIC_LINK})
|
|
message("Linking statically")
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC -static Eigen3::Eigen matplot ThreedBeamFEA ${TBB_BINARY_DIR}/libtbb_static.a #[[tbb_static]] pthread gfortran quadmath)
|
|
else()
|
|
# set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen matplot ThreedBeamFEA tbb pthread)
|
|
if(${USE_POLYSCOPE})
|
|
message("Using polyscope")
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC polyscope)
|
|
endif()
|
|
endif()
|
|
target_link_directories(MySources PUBLIC ${CMAKE_CURRENT_LIST_DIR}/boost_graph/libs)
|
|
target_include_directories(${PROJECT_NAME}
|
|
PUBLIC ${CMAKE_CURRENT_LIST_DIR}/boost_graph
|
|
PUBLIC ${vcglib_devel_SOURCE_DIR}
|
|
# PUBLIC ${threed-beam-fea_SOURCE_DIR}
|
|
PUBLIC ThreedBeamFEA
|
|
PUBLIC matplot
|
|
)
|
|
|
|
if(USE_ENSMALLEN)
|
|
##ENSMALLEN
|
|
set(ENSMALLEN_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/ensmallen)
|
|
download_project(PROJ ENSMALLEN
|
|
GIT_REPOSITORY https://github.com/mlpack/ensmallen.git
|
|
GIT_TAG master
|
|
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()
|
|
target_include_directories(${PROJECT_NAME} PUBLIC ${ARMADILLO_SOURCE_DIR}/include ${ENSMALLEN_SOURCE_DIR})
|
|
endif()
|