Skip to content

Commit

Permalink
Fix installation
Browse files Browse the repository at this point in the history
  • Loading branch information
codemercenary committed Feb 26, 2016
1 parent 7a85eb5 commit 9655b1a
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 8 deletions.
9 changes: 1 addition & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules")
include(AddPCH)
include(ConditionalSources)
include(InstallHeaders)

get_filename_component(AUTOWIRING_ROOT_DIR . ABSOLUTE)

Expand Down Expand Up @@ -157,14 +158,6 @@ install(FILES
COMPONENT autowiring
)

# Install public header files
install(
DIRECTORY ${PROJECT_SOURCE_DIR}/autowiring
DESTINATION include
COMPONENT autowiring
FILES_MATCHING PATTERN "*.h"
)

# Install autoboost headers on ARM, which still requires them
if(CMAKE_COMPILER_IS_GNUCC AND ("${CMAKE_CXX_COMPILER}" MATCHES "androideabi"))
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")
Expand Down
39 changes: 39 additions & 0 deletions cmake-modules/InstallHeaders.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Installs headers for the named target
# Syntax:
# install_headers TARGET <target> DESTINATION <destination> ...
#
# NOEXCLUDE_STDAFX Also install the precompiled header file
# <target> The target whose sources are to be installed
# <destination> The root of the destination folder where files will be copied
#
# Additional options are passed after FILES to the cmake install command
include(CMakeParseArguments)

function(install_headers)
set(options NOEXCLUDE_STDAFX)
set(oneValueArgs TARGET DESTINATION)
set(multiValueArgs)

cmake_parse_arguments(opt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

if(NOT opt_TARGET)
message(FATAL_ERROR "Cannot install files for a nonexistent target")
endif()

get_target_property(target_SRCS ${opt_TARGET} SOURCES)
foreach(src IN LISTS target_SRCS)
if(NOT ${opt_NOEXCLUDE_STDAFX} AND ${src} STREQUAL "stdafx.h")
continue()
endif()

get_filename_component(src_ext ${src} EXT)
if(src_ext STREQUAL ".h")
get_filename_component(src_rel ${src} DIRECTORY)
install(
FILES ${src}
DESTINATION ${opt_DESTINATION}/${src_rel}
${opt_UNPARSED_ARGUMENTS}
)
endif()
endforeach()
endfunction()
3 changes: 3 additions & 0 deletions src/autonet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ add_subdirectory(test)
# Install library
#

# Install public header files
install_headers(TARGET AutoNet DESTINATION include/autonet COMPONENT autowiring)

if(NOT NO_INSTALL_AUTONET AND NOT AUTOWIRING_IS_EMBEDDED)
install(TARGETS AutoNet EXPORT AutowiringTargets
DESTINATION lib
Expand Down
1 change: 1 addition & 0 deletions src/autotesting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ target_include_directories(
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/contrib/autoboost
)
install_headers(TARGET AutoTesting DESTINATION include/autotesting COMPONENT autowiring)

if(NOT AUTOWIRING_IS_EMBEDDED)
install(TARGETS AutoTesting EXPORT AutowiringTargets
Expand Down
35 changes: 35 additions & 0 deletions src/autowiring/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,38 @@ add_conditional_sources(
${PROJECT_SOURCE_DIR}/contrib/autoboost/libs/thread/src/future.cpp
)

add_conditional_sources(
Autowiring_SRCS
"TRUE"
GROUP_NAME "C++11"
FILES
C++11/boost_array.h
C++11/boost_atomic.h
C++11/boost_chrono.h
C++11/boost_exception_ptr.h
C++11/boost_functional.h
C++11/boost_future.h
C++11/boost_mutex.h
C++11/boost_rvalue.h
C++11/boost_shared_ptr.h
C++11/boost_system_error.h
C++11/boost_thread.h
C++11/boost_tuple.h
C++11/boost_type_traits.h
C++11/boost_utility.h
C++11/chrono_with_profiling_clock.h
C++11/cpp11.h
C++11/empty_file.h
C++11/make_unique.h
C++11/memory.h
C++11/memory_nostl11.h
C++11/mutex.h
C++11/tr1_unordered_map.h
C++11/tr1_unordered_set.h
C++11/type_index.h
C++11/unique_ptr.h
)

add_windows_sources(Autowiring_SRCS
auto_future_win.h
CoreThreadWin.cpp
Expand Down Expand Up @@ -239,6 +271,9 @@ target_include_directories(
"$<INSTALL_INTERFACE:include>"
)

# Install public header files
install_headers(TARGET Autowiring DESTINATION include/autowiring COMPONENT autowiring)

# Need multithreading services if available
find_package(Threads)
if(Threads_FOUND)
Expand Down

0 comments on commit 9655b1a

Please sign in to comment.