From efd1fd5ca4f16f3554053194b7d75f7512f6bef5 Mon Sep 17 00:00:00 2001 From: ManifoldFR Date: Mon, 7 Oct 2024 14:38:42 +0200 Subject: [PATCH] Add FindIpopt.cmake module --- find-external/Ipopt/FindIpopt.cmake | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 find-external/Ipopt/FindIpopt.cmake diff --git a/find-external/Ipopt/FindIpopt.cmake b/find-external/Ipopt/FindIpopt.cmake new file mode 100644 index 000000000..d772a288a --- /dev/null +++ b/find-external/Ipopt/FindIpopt.cmake @@ -0,0 +1,35 @@ +find_package(Ipopt CONFIG QUIET) + +if(Ipopt_FOUND) + message(DEBUG "Found Ipopt (using IpoptConfig.cmake or ipopt-config.cmake)") +else() + find_package(PkgConfig QUIET) + if(NOT PKG_CONFIG_FOUND) + message(FATAL_ERROR "pkg-config not found!") + endif() + pkg_check_modules(Ipopt REQUIRED ipopt) + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args( + Ipopt + FAIL_MESSAGE DEFAULT_MSG + REQUIRED_VARS Ipopt_INCLUDE_DIRS Ipopt_LIBRARIES + VERSION_VAR Ipopt_VERSION + ) + + message(STATUS " Ipopt library dirs: ${Ipopt_LIBRARY_DIRS}") + message(STATUS " Ipopt include dirs: ${Ipopt_INCLUDE_DIRS}") + add_library(ipopt SHARED IMPORTED) + find_library(ipopt_lib_path NAMES ipopt PATHS ${Ipopt_LIBRARY_DIRS}) + message(STATUS " Ipopt library ipopt found at ${ipopt_lib_path}") + set_target_properties(ipopt PROPERTIES IMPORTED_LOCATION ${ipopt_lib_path}) + target_include_directories(ipopt INTERFACE ${Ipopt_INCLUDE_DIRS}) + + if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC") + else() + target_compile_definitions(ipopt INTERFACE HAVE_CSTDDEF) + endif() + target_compile_options(ipopt INTERFACE ${Ipopt_CFLAGS_OTHER}) + + add_library(Ipopt::Ipopt ALIAS ipopt) +endif()