Permalink
Browse files

Updated CMakeLists: Cleaner non-flattened installation.

  • Loading branch information...
1 parent a8b58c4 commit f731d1fc40cc7a5e6198194481a79df7935a2e9c @samueldr samueldr committed May 22, 2015
Showing with 21 additions and 4 deletions.
  1. +21 −4 CMakeLists.txt
View
@@ -18,8 +18,17 @@ set(JSONBOX_SOURCES
src/Convert.cpp
)
set(JSONBOX_HEADERS
+ include/JsonBox/Convert.h
+ include/JsonBox/Escaper.h
+ include/JsonBox/Grammar.h
+ include/JsonBox/IndentCanceller.h
+ include/JsonBox/Indenter.h
+ include/JsonBox/JsonParsingError.h
+ include/JsonBox/JsonWritingError.h
+ include/JsonBox/OutputFilter.h
+ include/JsonBox/SolidusEscaper.h
+ include/JsonBox/Value.h
include/JsonBox.h
- ${CMAKE_CURRENT_BINARY_DIR}/Export.h
)
# build library
@@ -41,6 +50,14 @@ export(TARGETS JsonBox
FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
)
+# Macro used to install headers while keeping the directory hierarchy.
+MACRO(INSTALL_HEADERS_WITH_DIRECTORY HEADER_LIST)
+ FOREACH(HEADER ${${HEADER_LIST}})
+ STRING(REGEX MATCH "(.*)[/\\]" DIR ${HEADER})
+ INSTALL(FILES ${HEADER} COMPONENT dev DESTINATION ${DIR})
+ ENDFOREACH(HEADER)
+ENDMACRO(INSTALL_HEADERS_WITH_DIRECTORY)
+
# install
install(TARGETS JsonBox
COMPONENT lib
@@ -50,11 +67,11 @@ install(TARGETS JsonBox
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
-install(FILES ${JSONBOX_HEADERS}
+INSTALL_HEADERS_WITH_DIRECTORY(JSONBOX_HEADERS)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Export.h
COMPONENT dev
- DESTINATION include
+ DESTINATION include/JsonBox
)
-install(DIRECTORY include/ DESTINATION include)
install(EXPORT ${PROJECT_NAME}
DESTINATION lib${LIB_SUFFIX}/cmake
FILE ${PROJECT_NAME}Config.cmake

0 comments on commit f731d1f

Please sign in to comment.