aboutsummaryrefslogtreecommitdiff
path: root/src/CMakeLists.txt
diff options
context:
space:
mode:
authorGregor Burger <gregor.burger@bhs-technologies.com>2018-11-20 11:48:03 +0100
committerGarrett D'Amore <garrett@damore.org>2018-11-22 12:28:27 -0800
commitd6bb25e1e0a25cb5aa781ac4f90b513fd5624f50 (patch)
treef081a6868a6c3d88b4df64ef20a38fb3e83925d1 /src/CMakeLists.txt
parent8a9fd805d96201c780610b765f9e6dd9f2eda642 (diff)
downloadnng-d6bb25e1e0a25cb5aa781ac4f90b513fd5624f50.tar.gz
nng-d6bb25e1e0a25cb5aa781ac4f90b513fd5624f50.tar.bz2
nng-d6bb25e1e0a25cb5aa781ac4f90b513fd5624f50.zip
move all public headers to include/nng/ folder
This change makes embedding nng + nggpp (or other projects depending on nng) in cmake easier. The header files are moved to a separate include directory. This also makes installation of the headers easier, and allows clearer identification of private vs public heade files. Some additional cleanups were performed by @gedamore, but the main credit for this change belongs with @gregorburger.
Diffstat (limited to 'src/CMakeLists.txt')
-rw-r--r--src/CMakeLists.txt22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 960e912c..dff34f9f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -24,10 +24,9 @@
# IN THE SOFTWARE.
#
-set (NNG_HDRS nng.h)
set (NNG_SRCS
nng.c
- nng.h
+ ${PROJECT_SOURCE_DIR}/include/nng/nng.h
core/defs.h
@@ -246,7 +245,10 @@ set_target_properties (${PROJECT_NAME} ${PROJECT_NAME}
target_link_libraries (${PROJECT_NAME} PRIVATE ${NNG_LIBS})
-target_include_directories (${PROJECT_NAME} INTERFACE $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
+target_include_directories (${PROJECT_NAME} INTERFACE $<INSTALL_INTERFACE:include>
+$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
+
+target_include_directories (${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/include)
install (TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-target
@@ -263,14 +265,10 @@ install (EXPORT ${PROJECT_NAME}-target
COMPONENT Library
)
-# Install the header files. It would be much better if we could use
-# the PUBLIC_HEADER facility, but it stupidly flattens the directories.
-foreach (f ${NNG_HDRS})
- get_filename_component(d ${f} DIRECTORY)
- install(FILES ${f}
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nng/${d}
- COMPONENT Headers)
-endforeach()
+# Install the header files.
+install(DIRECTORY ../include/nng
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+ COMPONENT Headers)
# Promote settings to parent
set(NNG_LIBS ${NNG_LIBS} PARENT_SCOPE)
@@ -296,7 +294,7 @@ write_basic_package_version_file("${version_config}"
VERSION ${NNG_PACKAGE_VERSION}
COMPATIBILITY SameMajorVersion
)
-configure_package_config_file(${CMAKE_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake.in "${project_config}"
+configure_package_config_file(${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}-config.cmake.in "${project_config}"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
PATH_VARS INCLUDE_INSTALL_DIRS)