chiark / gitweb /
Cleaner way to fix ctest (#144)
[nlopt.git] / CMakeLists.txt
index 4996bb3de0bc917848b6647a5351b86460dad4be..48644780edc2ab27db9f0b4c1ceece11054442bf 100644 (file)
@@ -236,11 +236,11 @@ target_include_directories (${nlopt_lib} PRIVATE
   api)\r
 \r
 get_target_property (NLOPT_PRIVATE_INCLUDE_DIRS ${nlopt_lib} INCLUDE_DIRECTORIES)\r
-target_include_directories (${nlopt_lib} INTERFACE "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/api>")\r
+target_include_directories (${nlopt_lib} INTERFACE "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/api>" "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")\r
 \r
 if (BUILD_SHARED_LIBS)\r
-  target_compile_definitions (${nlopt_lib} INTERFACE -DNLOPT_DLL)\r
-  target_compile_definitions (${nlopt_lib} INTERFACE -DNLOPT_DLL_EXPORT)\r
+  target_compile_definitions (${nlopt_lib} PUBLIC -DNLOPT_DLL)\r
+  target_compile_definitions (${nlopt_lib} PRIVATE -DNLOPT_DLL_EXPORT)\r
 endif ()\r
 \r
 # pass -fPIC in case swig module is built with static library\r
@@ -320,16 +320,17 @@ set (CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${NLOPT_VERSION_STRING
 include (CPack)\r
 \r
 # configuration files\r
-export (TARGETS ${nlopt_lib} FILE ${PROJECT_BINARY_DIR}/NLoptLibraryDepends.cmake)\r
+export (TARGETS ${nlopt_lib} NAMESPACE NLopt:: FILE ${PROJECT_BINARY_DIR}/NLoptLibraryDepends.cmake)\r
 \r
 # Install the export set for use with the install-tree\r
 install(EXPORT NLoptLibraryDepends\r
+        NAMESPACE NLopt::\r
         DESTINATION ${RELATIVE_INSTALL_CMAKE_DIR}\r
         COMPONENT Development)\r
 \r
 # Create a NLOPTConfig.cmake file for the use from the install tree\r
 # and install it\r
-set (NLOPT_LIBRARIES ${nlopt_lib})\r
+set (NLOPT_LIBRARIES "NLopt::${nlopt_lib}")\r
 \r
 set (NLOPT_CMAKE_DIR "${INSTALL_CMAKE_DIR}")\r
 file (RELATIVE_PATH rel_include_dir "${NLOPT_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}")\r