diff --git a/CMakeLists.txt b/CMakeLists.txt index 08736e4..0da29b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,16 +13,18 @@ option(BUILD_SHARED_LIBS "Enable compilation of shared libraries" OFF) #set(BLA_VENDOR Intel10_64lp) find_package(BLAS) find_package(LAPACK) - +include(GNUInstallDirs) include(FetchContent) # get seldon from github -FetchContent_Declare(seldon GIT_REPOSITORY https://github.com/libseldon/seldon.git) +set(FETCHCONTENT_SOURCE_DIR_SELDON /home/prudhomm/Devel/seldon) +FetchContent_Declare(seldon GIT_REPOSITORY https://github.com/feelpp/seldon.git ) FetchContent_GetProperties(seldon) if(NOT seldon_POPULATED) FetchContent_Populate(seldon) endif() -add_library(seldon SHARED ${seldon_SOURCE_DIR}/Seldon.cpp) +add_library(seldon SHARED ${seldon_SOURCE_DIR}/Seldon.cpp) +#target_compile_definitions(seldon PUBLIC -DSELDON_WITH_COMPILED_LIBRARY) target_compile_features(seldon PUBLIC cxx_std_17) target_link_libraries(seldon ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}) @@ -34,7 +36,13 @@ add_dependencies(seldon seldon_link_target) target_include_directories(seldon PUBLIC $ $ ) - + install(TARGETS seldon EXPORT VerdandiTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) + find_library(MATH_LIBRARY_FOR_LUA m) message(STATUS "${MATH_LIBRARY_FOR_LUA}") find_package(Lua 5.2) @@ -65,6 +73,12 @@ target_link_libraries(ops PUBLIC lua) target_include_directories(ops PUBLIC $ $ ) +install(TARGETS ops EXPORT VerdandiTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) add_subdirectory(share) diff --git a/example/quadratic_model/CMakeLists.txt b/example/quadratic_model/CMakeLists.txt index be61343..0421877 100644 --- a/example/quadratic_model/CMakeLists.txt +++ b/example/quadratic_model/CMakeLists.txt @@ -11,3 +11,7 @@ add_dependencies(quadratic_model quadratic_model_forward) add_executable(quadratic_model_optimal_interpolation optimal_interpolation.cpp) target_link_libraries(quadratic_model_optimal_interpolation verdandi) add_dependencies(quadratic_model quadratic_model_optimal_interpolation) + +add_executable(quadratic_model_nudging nudging.cpp) +target_link_libraries(quadratic_model_nudging verdandi) +add_dependencies(quadratic_model quadratic_model_nudging) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index f9733a7..6e263de 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -18,4 +18,24 @@ set_property(TARGET _verdandi PROPERTY SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE) set_property(TARGET _verdandi PROPERTY INCLUDE_DIRECTORIES ${libops_SOURCE_DIR} ${seldon_SOURCE_DIR}/ ${Python_INCLUDE_DIRS}) set_property(TARGET _verdandi PROPERTY SWIG_COMPILE_DEFINITIONS SELDON_EXCLUDE_FROM_EXPLICIT_INSTANTIATION VERDANDI_DEBUG_LEVEL_4 VERDANDI_PYTHON_VERSION=${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}) target_link_libraries(_verdandi PUBLIC verdandi ops) -target_include_directories(_verdandi PRIVATE ${Python3_INCLUDE_DIRS} ) \ No newline at end of file +target_include_directories(_verdandi PRIVATE ${Python3_INCLUDE_DIRS} ) + +if (DEFINED PYTHON_SITE_PACKAGES) + set (VERDANDI_PYTHON_MODULE_PATH ${PYTHON_SITE_PACKAGES}) +else () + execute_process (COMMAND ${Python3_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(plat_specific=True, prefix='${CMAKE_INSTALL_PREFIX}'))" + OUTPUT_VARIABLE _ABS_PYTHON_MODULE_PATH + RESULT_VARIABLE _PYTHON_pythonlib_result + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if (_PYTHON_pythonlib_result) + message (SEND_ERROR "Could not run ${Python3_EXECUTABLE}") + endif () + + get_filename_component (_ABS_PYTHON_MODULE_PATH ${_ABS_PYTHON_MODULE_PATH} ABSOLUTE) + file (RELATIVE_PATH VERDANDI_PYTHON_MODULE_PATH ${CMAKE_INSTALL_PREFIX} ${_ABS_PYTHON_MODULE_PATH}) +endif () +set (VERDANDI_PYTHON${PYTHON_VERSION_MAJOR}_MODULE_PATH ${VERDANDI_PYTHON_MODULE_PATH}) +message(STATUS "[verdandi] python module path: ${VERDANDI_PYTHON_MODULE_PATH}") +install(TARGETS _verdandi DESTINATION ${VERDANDI_PYTHON_MODULE_PATH}) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/verdandi.py DESTINATION ${VERDANDI_PYTHON_MODULE_PATH}) \ No newline at end of file diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt index 499a292..fc160f8 100644 --- a/share/CMakeLists.txt +++ b/share/CMakeLists.txt @@ -5,4 +5,12 @@ target_include_directories(verdandi PUBLIC $ $ $ ) -target_link_libraries(verdandi PUBLIC seldon ops lua) \ No newline at end of file +target_link_libraries(verdandi PUBLIC seldon ops lua) + + +install(TARGETS verdandi EXPORT VerdandiTargets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + ) \ No newline at end of file