11#
22#[[
33
4- Finds Ipopt include directory and libraries and exports target `Ipopt `
4+ Finds Ipopt include directory and libraries and exports target `IPOPT `
55
66User may set:
77- IPOPT_ROOT_DIR
@@ -26,7 +26,6 @@ find_library(
2626
2727if (IPOPT_LIBRARY)
2828 set (IPOPT_LIBRARY CACHE FILEPATH "Path to Ipopt library" )
29- message (STATUS "Found Ipopt library: " ${IPOPT_LIBRARY} )
3029 get_filename_component (
3130 IPOPT_LIBRARY_DIR
3231 ${IPOPT_LIBRARY}
@@ -56,25 +55,12 @@ find_path(
5655 include /coin-or
5756 include /coinor )
5857
59- if (IPOPT_LIBRARY)
60- message (STATUS "Found Ipopt include: ${IPOPT_INCLUDE_DIR} " )
61- mark_as_advanced (IPOPT_INCLUDE_DIR )
58+ include (FindPackageHandleStandardArgs )
59+ find_package_handle_standard_args (Ipopt REQUIRED_VARS IPOPT_LIBRARY IPOPT_INCLUDE_DIR)
60+ mark_as_advanced (IPOPT_LIBRARY IPOPT_INCLUDE_DIR )
61+
62+ if (Ipopt_FOUND AND NOT TARGET IPOPT)
6263 add_library (IPOPT INTERFACE IMPORTED )
6364 target_link_libraries (IPOPT INTERFACE ${IPOPT_LIBRARY} )
6465 target_include_directories (IPOPT INTERFACE ${IPOPT_INCLUDE_DIR} )
65- else ()
66- if (NOT IPOPT_ROOT_DIR)
67- message (STATUS "Ipopt dir not found! Please provide correct filepath." )
68- set (IPOPT_DIR
69- ${IPOPT_DIR}
70- CACHE PATH "Path to Ipopt installation root." )
71- unset (IPOPT_INCLUDE_DIR CACHE )
72- unset (IPOPT_LIBRARY CACHE )
73- unset (IPOPT_LIBRARY_DIR CACHE )
74- elseif (NOT IPOPT_LIB)
75- message (STATUS "Ipopt library not found! Please provide correct filepath." )
76- endif ()
77- if (IPOPT_ROOT_DIR AND NOT IPOPT_INCLUDE_DIR)
78- message (STATUS "Ipopt include directory not found! Please provide correct path." )
79- endif ()
8066endif ()
0 commit comments