diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 07c723fd17b..933af298f33 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,20 +1,42 @@ -#install commands for headers -FILE(GLOB files ${CMAKE_CURRENT_SOURCE_DIR}/*.h*) -INSTALL(FILES ${files} DESTINATION include) -# Copy the file to directory matching the install directory -file(COPY ${files} DESTINATION "${PROJECT_BINARY_DIR}/include") - -FILE(GLOB files ${CMAKE_CURRENT_SOURCE_DIR}/*.inl) -INSTALL(FILES ${files} DESTINATION include) -# Copy the file to directory matching the install directory -file(COPY ${files} DESTINATION "${PROJECT_BINARY_DIR}/include") - +# Put all hcc headers into the hcc-headers target +# .h and .hpp headers +FILE(GLOB H_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.h*) +# .inl headers +FILE(GLOB INL_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/*.inl) # N4494 headers FILE(GLOB N4494 ${CMAKE_CURRENT_SOURCE_DIR}/coordinate ${CMAKE_CURRENT_SOURCE_DIR}/array_view) -INSTALL(FILES ${N4494} DESTINATION include) -# Copy the file to directory matching the install directory -file(COPY ${N4494} DESTINATION "${PROJECT_BINARY_DIR}/include") + + +set(HCC_HEADERS) +#Obtain the names of each Header File +foreach(InFName ${H_HEADERS} ${INL_HEADERS} ${N4494}) + STRING(REGEX REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/ "" OutFName ${InFName}) + set(HCC_HEADERS ${HCC_HEADERS} "${OutFName}") +endforeach(InFName) + + +# Set location for output directory +set(output_dir "${PROJECT_BINARY_DIR}/include") +set(out_files) +foreach( f ${HCC_HEADERS} ) + set( src ${CMAKE_CURRENT_SOURCE_DIR}/${f} ) + set( dst ${output_dir}/${f} ) + add_custom_command(OUTPUT ${dst} + DEPENDS ${src} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} + COMMENT "Copying HCC's ${f}...") + list(APPEND out_files ${dst}) +endforeach( f ) + +# Create target for hcc-headers and set dependencies +add_custom_target(hcc-headers ALL DEPENDS ${out_files}) +add_dependencies(world hcc-headers) + +# Install command for headers +install(FILES ${HCC_HEADERS} + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + DESTINATION include) # PSTL headers ADD_SUBDIRECTORY(experimental) diff --git a/include/experimental/CMakeLists.txt b/include/experimental/CMakeLists.txt index d525b05530e..a46f2929874 100644 --- a/include/experimental/CMakeLists.txt +++ b/include/experimental/CMakeLists.txt @@ -1,11 +1,61 @@ -# PSTL headers -FILE(GLOB PSTL ${CMAKE_CURRENT_SOURCE_DIR}/algorithm - ${CMAKE_CURRENT_SOURCE_DIR}/exception_list - ${CMAKE_CURRENT_SOURCE_DIR}/execution_policy - ${CMAKE_CURRENT_SOURCE_DIR}/numeric) -INSTALL(FILES ${PSTL} DESTINATION include/experimental) -# Copy the file to directory matching the install directory -file(COPY ${PSTL} DESTINATION "${PROJECT_BINARY_DIR}/include/experimental") - -# PSTL internal headers -ADD_SUBDIRECTORY(impl) +# Here we have PSTL header files inside experimental directory and impl sub-directory. +# All PSTL headers should be in the same pstl-headers target, but different output dir + +# PSTL headers from experimental/ +set(PSTL_EXP_HEADERS + algorithm + exception_list + execution_policy + numeric) + +# PSTL headers from experimental/impl/ +FILE(GLOB PSTL_IMPL ${CMAKE_CURRENT_SOURCE_DIR}/impl/*.inl) + +# Obtain the names of each impl header and add to PSTL +foreach(InFName ${PSTL_IMPL}) + STRING(REGEX REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/ "" OutFName ${InFName}) + set(PSTL_IMPL_HEADERS ${PSTL_IMPL_HEADERS} "${OutFName}") +endforeach(InFName) + +# Set location for exp/ output directory +set(exp_output_dir "${PROJECT_BINARY_DIR}/include/experimental") +# Set location for exp/impl/ output directory +set(impl_output_dir "${PROJECT_BINARY_DIR}/include/experimental/impl") + +set(exp_out_files) +set(impl_out_files) + +foreach( f ${PSTL_EXP_HEADERS} ) + set( src ${CMAKE_CURRENT_SOURCE_DIR}/${f} ) + set( dst ${exp_output_dir}/${f} ) + add_custom_command(OUTPUT ${dst} + DEPENDS ${src} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} + COMMENT "Copying HCC's ${f}...") + list(APPEND exp_out_files ${dst}) +endforeach( f ) + +foreach( f ${PSTL_IMPL_HEADERS} ) + set( src ${CMAKE_CURRENT_SOURCE_DIR}/${f} ) + set( dst ${impl_output_dir}/${f} ) + add_custom_command(OUTPUT ${dst} + DEPENDS ${src} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} + COMMENT "Copying HCC's ${f}...") + list(APPEND impl_out_files ${dst}) +endforeach( f ) + +# Create target for pstl-headers and set dependencies +add_custom_target(pstl-headers ALL DEPENDS ${exp_out_files} ${impl_out_files}) +add_dependencies(world pstl-headers) + +# Install command for PSTL exp headers +install(FILES ${PSTL_EXP_HEADERS} + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + DESTINATION include/experimental) + +# Install command for PSTL impl headers +install(FILES ${PSTL_IMPL_HEADERS} + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + DESTINATION include/experimental/impl) + diff --git a/include/experimental/impl/CMakeLists.txt b/include/experimental/impl/CMakeLists.txt deleted file mode 100644 index ab98f33569a..00000000000 --- a/include/experimental/impl/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# PSTL headers -FILE(GLOB PSTL ${CMAKE_CURRENT_SOURCE_DIR}/*.inl) -INSTALL(FILES ${PSTL} DESTINATION include/experimental/impl) -# Copy the file to directory matching the install directory -file(COPY ${PSTL} DESTINATION "${PROJECT_BINARY_DIR}/include/experimental/impl") -