Refactoring

This commit is contained in:
iasonmanolas 2022-08-08 12:03:04 +03:00
parent dd21445f52
commit 01dff95f9d
1 changed files with 18 additions and 13 deletions

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.0)
project(MySources)
file(GLOB MySourcesFiles ${CMAKE_CURRENT_LIST_DIR}/*.hpp ${CMAKE_CURRENT_LIST_DIR}/*.cpp)
add_library(${PROJECT_NAME} ${MySourcesFiles} )
add_library(${PROJECT_NAME} STATIC ${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.
@ -21,8 +21,8 @@ endif()
file(MAKE_DIRECTORY ${EXTERNAL_DEPS_DIR})
set(DRMSimulationModelDir "/home/iason/Coding/Libraries/DRMSimulationModel")
message("drm dir:" ${DRMSimulationModelDir})
add_subdirectory(${DRMSimulationModelDir} "/home/iason/Coding/build/DRMSimulationModel")
set(DRMSimulationModelBuildDir ${CMAKE_BINARY_DIR}/_deps)
add_subdirectory(${DRMSimulationModelDir} ${DRMSimulationModelBuildDir})
target_link_libraries(${PROJECT_NAME} PUBLIC DRMSimulationModel)
target_include_directories(${PROJECT_NAME} PUBLIC ${DRMSimulationModelDir})
@ -45,13 +45,17 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${DRMSimulationModelDir})
#add_compile_definitions(DLIB_DEFINED)
## polyscope
FetchContent_Declare(polyscope
#if(NOT TARGET polyscope AND ${USE_POLYSCOPE})
FetchContent_Declare(polyscope
GIT_REPOSITORY https://github.com/nmwsharp/polyscope.git
GIT_TAG master
)
FetchContent_MakeAvailable(polyscope)
target_include_directories(${PROJECT_NAME} PUBLIC ${polyscope_SOURCE_DIR}/include)
target_link_libraries(${PROJECT_NAME} PUBLIC polyscope)
FetchContent_MakeAvailable(polyscope)
target_include_directories(${PROJECT_NAME} PUBLIC ${polyscope_SOURCE_DIR}/include)
# target_include_directories(${PROJECT_NAME} PUBLIC ${polyscope_SOURCE_DIR}/deps/imgui)
target_sources(${PROJECT_NAME} PUBLIC ${polyscope_SOURCE_DIR}/deps/imgui/imgui/misc/cpp/imgui_stdlib.h ${polyscope_SOURCE_DIR}/deps/imgui/imgui/misc/cpp/imgui_stdlib.cpp)
target_link_libraries(${PROJECT_NAME} PUBLIC polyscope)
#endif()
#if(NOT TARGET polyscope AND ${USE_POLYSCOPE})
# set(POLYSCOPE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/polyscope)
# download_project(PROJ POLYSCOPE
@ -63,7 +67,6 @@ target_link_libraries(${PROJECT_NAME} PUBLIC polyscope)
# )
# 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)
# message("Using polyscope..")
# target_include_directories(${PROJECT_NAME} PUBLIC ${POLYSCOPE_SOURCE_DIR}/include)
@ -126,7 +129,7 @@ if(${MYSOURCES_STATIC_LINK})
endif()
if(${MYSOURCES_STATIC_LINK})
message("Linking statically here")
target_link_libraries(${PROJECT_NAME} PUBLIC -static Eigen3::Eigen matplot pthread gfortran quadmath)
target_link_libraries(${PROJECT_NAME} PUBLIC #[[-static]] Eigen3::Eigen matplot pthread gfortran quadmath)
else()
target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen matplot tbb pthread)
endif()
@ -179,6 +182,7 @@ download_project(PROJ ENSMALLEN
)
target_include_directories(${PROJECT_NAME}
PUBLIC ${ENSMALLEN_SOURCE_DIR}/include)
message("ens dir:" ${ENSMALLEN_SOURCE_DIR})
add_compile_definitions(USE_ENSMALLEN)
#endif()
@ -253,5 +257,6 @@ if(NOT TARGET tbb_static AND NOT TARGET tbb)
GIT_TAG master
)
FetchContent_MakeAvailable(tbb)
target_link_libraries(${PROJECT_NAME} PRIVATE tbb_static)
# target_link_libraries(${PROJECT_NAME} PRIVATE tbb_static)
target_link_libraries(${PROJECT_NAME} PRIVATE tbb)
endif()