diff --git a/CMakeLists.txt b/CMakeLists.txt index 5932e5c..0c42e97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ target_include_directories(lion SYSTEM INTERFACE "$/${CMAKE_INSTALL_INCLUDEDIR}/lion/thirdparty/include>" ) -target_link_libraries(lion INTERFACE ipopt blaslapack tinyxml2 fortran_libraries) +target_link_libraries(lion INTERFACE ipopt blaslapack tinyxml2 fortran_libraries cppad) # Create a lion header only add_library(header_only INTERFACE) @@ -104,7 +104,7 @@ install(FILES ${version_file} ${config_file} DESTINATION ${cmake_files_install_dir}) # Export the targets -install(TARGETS lion ipopt blaslapack tinyxml2 header_only fortran_libraries +install(TARGETS lion ipopt blaslapack tinyxml2 header_only fortran_libraries cppad EXPORT ${targets_export_name} RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" diff --git a/cmake/Findcppad.cmake b/cmake/Findcppad.cmake index 2feffa5..ab7dd1e 100644 --- a/cmake/Findcppad.cmake +++ b/cmake/Findcppad.cmake @@ -1,8 +1,35 @@ if (NOT cppad_FOUND) find_path(CPPAD_INCLUDE_DIR cppad.hpp PATHS ${CMAKE_BINARY_DIR}/lion/thirdparty/include/cppad) - - if (CPPAD_INCLUDE_DIR) + + find_library(CPPAD_LIBRARY NAMES cppad_lib PATHS ${CMAKE_BINARY_DIR}/lion/thirdparty/lib HINTS ${CMAKE_BINARY_DIR}/lion/thirdparty/lib NO_DEFAULT_PATH) + + if (CPPAD_INCLUDE_DIR AND CPPAD_LIBRARY) set(cppad_FOUND YES) + + get_filename_component(CPPAD_LIB_NAME ${CPPAD_LIBRARY} NAME) + + if (APPLE) + # Change relative paths by absolute path + execute_process(COMMAND ${CMAKE_INSTALL_NAME_TOOL} -id "@rpath/${CPPAD_LIB_NAME}" ${CPPAD_LIBRARY}) + endif() + + + add_library(cppad INTERFACE) + + + file(GLOB CPPAD_LIB_ALL_FILES "${CMAKE_BINARY_DIR}/lion/thirdparty/lib/libcppad_lib*") + + set(CPPAD_LIBRARY_INSTALL ${CMAKE_INSTALL_FULL_LIBDIR}/${CPPAD_LIB_NAME}) + + target_link_libraries(cppad INTERFACE + "$" + "$/${CMAKE_INSTALL_LIBDIR}/${CPPAD_LIB_NAME}>") + + + foreach(t ${CPPAD_LIB_ALL_FILES}) + install(FILES "${t}" TYPE LIB) + endforeach() + else() set(cppad_FOUND NO) endif() diff --git a/cmake/compilerflags.cmake b/cmake/compilerflags.cmake index 9d985cd..3c58d41 100644 --- a/cmake/compilerflags.cmake +++ b/cmake/compilerflags.cmake @@ -1,4 +1,4 @@ -add_compile_options(-Wfatal-errors -Werror -Wall) +add_compile_options(-Wfatal-errors -Werror -Wall -DCPPAD_DEBUG_AND_RELEASE) if (CMAKE_BUILD_TYPE MATCHES "Debug") add_compile_options(-O0 -gdwarf-2) diff --git a/cmake/third-party/cppad.cmake b/cmake/third-party/cppad.cmake index 715a8f9..389f707 100644 --- a/cmake/third-party/cppad.cmake +++ b/cmake/third-party/cppad.cmake @@ -2,13 +2,13 @@ if ( ${BUILD_CPPAD} ) include (ExternalProject) ExternalProject_Add(cppad GIT_REPOSITORY https://github.com/coin-or/CppAD.git - GIT_TAG 6856fdde535d2a7634a6fc36d8787a72166dce91 + GIT_TAG master CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${THIRD_PARTY_DIR}/lion/thirdparty -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} PREFIX "${THIRD_PARTY_DIR}/cppad" SOURCE_DIR ${THIRD_PARTY_DIR}/cppad/source BINARY_DIR ${THIRD_PARTY_DIR}/cppad/build INSTALL_DIR ${THIRD_PARTY_DIR}/lion/thirdparty ) - add_dependencies(cppad ipopt) +# add_dependencies(cppad ipopt) endif()