Skip to content

Commit

Permalink
cmake interfaces and better installation. (#771)
Browse files Browse the repository at this point in the history
* cmake interfaces and better installation.

* added missing link_libraries in test

* added -version.cmake

* fixed include in header check

* added missing install prefix
  • Loading branch information
verri authored and ericniebler committed Jan 29, 2018
1 parent 4ade4af commit 2ff4cf2
Show file tree
Hide file tree
Showing 12 changed files with 249 additions and 7 deletions.
41 changes: 34 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,28 @@ include(CTest)

enable_testing()

include_directories(include)
add_library(meta INTERFACE)
target_include_directories(meta INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>)
target_include_directories(meta SYSTEM INTERFACE $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>)

add_library(range-v3 INTERFACE)
target_include_directories(range-v3 INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>)
target_include_directories(range-v3 SYSTEM INTERFACE $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>)
target_link_libraries(range-v3 INTERFACE meta)

add_subdirectory(doc)
add_subdirectory(test)
add_subdirectory(example)
add_subdirectory(perf)

if(NOT RANGE_V3_NO_TESTING)
add_subdirectory(test)
endif()

if(NOT RANGE_V3_NO_EXAMPLE)
add_subdirectory(example)
endif()

if(NOT RANGE_V3_NO_PERF)
add_subdirectory(perf)
endif()

# Test for <thread>
try_compile(RANGE_V3_TRY_THREAD ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/thread_test_code.cpp)
Expand Down Expand Up @@ -114,6 +131,16 @@ if(NOT RANGE_V3_NEW_VERSION_HPP STREQUAL RANGE_V3_OLD_VERSION_HPP)
message(" conan upload --all range-v3/${RANGE_V3_VERSION}@ericniebler/stable")
endif()


install(DIRECTORY include/ DESTINATION include
FILES_MATCHING PATTERN "*.hpp")
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/range-v3-config-version.cmake
VERSION ${RANGE_V3_VERSION}
COMPATIBILITY ExactVersion
)

install(TARGETS meta range-v3 EXPORT range-v3-targets DESTINATION lib)
install(EXPORT range-v3-targets FILE range-v3-config.cmake DESTINATION lib/cmake/range-v3)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/range-v3-config-version.cmake
DESTINATION lib/cmake/range-v3)
install(DIRECTORY include/ DESTINATION include FILES_MATCHING PATTERN "*.hpp")
1 change: 1 addition & 0 deletions cmake/TestHeaders.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ int main() { }
${ARGS_EXCLUDE_FROM_ALL}
"${CMAKE_CURRENT_BINARY_DIR}/headers/${directory}/${filename}.cpp"
)
target_include_directories(test.header.${target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
if (ARGS_LINK_LIBRARIES)
target_link_libraries(test.header.${target} ${ARGS_LINK_LIBRARIES})
endif()
Expand Down
6 changes: 6 additions & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@
ranges_append_flag(RANGES_HAS_WNO_MISSING_BRACES -Wno-missing-braces)

add_executable(comprehensions comprehensions.cpp)
target_link_libraries(comprehensions range-v3)
add_test(example.comprehensions, comprehensions)

add_executable(hello hello.cpp)
target_link_libraries(hello range-v3)
add_test(example.hello, hello)

add_executable(count count.cpp)
target_link_libraries(count range-v3)
add_test(example.count, count)

add_executable(count_if count_if.cpp)
target_link_libraries(count_if range-v3)
add_test(example.count_if, count_if)

# add_executable(fibonacci fibonacci.cpp)
# target_link_libraries(fibonacci range-v3)
# add_test(example.fibonacci, fibonacci)

# Guarded with a variable because the calendar example causes gcc to puke.
Expand All @@ -26,6 +31,7 @@ if(RANGES_BUILD_CALENDAR_EXAMPLE)
if (Boost_FOUND)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
add_executable(calendar calendar.cpp)
target_link_libraries(calendar range-v3)
target_link_libraries(calendar ${Boost_LIBRARIES})
message ("boost: ${Boost_LIBRARY_DIRS}")
target_compile_definitions(calendar PUBLIC -DBOOST_NO_AUTO_PTR)
Expand Down
2 changes: 2 additions & 0 deletions perf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
add_executable(counted_insertion_sort counted_insertion_sort.cpp)
target_link_libraries(counted_insertion_sort range-v3)

add_executable(sort_patterns sort_patterns.cpp)
target_link_libraries(sort_patterns range-v3)
15 changes: 15 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,61 @@ add_subdirectory(view)
add_subdirectory(experimental)

add_executable(config config.cpp)
target_link_libraries(config range-v3)
add_test(test.config config)

add_executable(container_conversion container_conversion.cpp)
target_link_libraries(container_conversion range-v3)
add_test(test.container_conversion container_conversion)

add_executable(constexpr_core constexpr_core.cpp)
target_link_libraries(constexpr_core range-v3)
add_test(test.constexpr_core constexpr_core)

add_executable(view_facade view_facade.cpp)
target_link_libraries(view_facade range-v3)
add_test(test.view_facade view_facade)

add_executable(view_adaptor view_adaptor.cpp)
target_link_libraries(view_adaptor range-v3)
add_test(test.view_adaptor view_adaptor)

add_executable(index index.cpp)
target_link_libraries(index range-v3)
add_test(test.index index)

add_executable(iterator_range iterator_range.cpp)
target_link_libraries(iterator_range range-v3)
add_test(test.iterator_range iterator_range)

add_executable(multiple multiple1.cpp multiple2.cpp)
target_link_libraries(multiple range-v3)
add_test(test.multiple multiple)

add_executable(distance distance.cpp)
target_link_libraries(distance range-v3)
add_test(test.distance distance)

add_executable(to_container to_container.cpp)
target_link_libraries(to_container range-v3)
add_test(test.to_container to_container)

add_executable(getlines getlines.cpp)
target_link_libraries(getlines range-v3)
add_test(test.getlines getlines)

add_executable(istream_range istream_range.cpp)
target_link_libraries(istream_range range-v3)
add_test(test.istream_range istream_range)

add_executable(bug474 bug474.cpp)
target_link_libraries(bug474 range-v3)
add_test(test.bug474 bug474)

add_executable(bug566 bug566.cpp)
target_link_libraries(bug566 range-v3)
add_test(test.bug566 bug566)

add_executable(span span.cpp)
target_link_libraries(span range-v3)
add_test(test.span span)
19 changes: 19 additions & 0 deletions test/action/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,56 +1,75 @@
add_executable(act.concepts cont_concepts.cpp)
target_link_libraries(act.concepts range-v3)
add_test(test.act.concepts act.concepts)

add_executable(act.drop drop.cpp)
target_link_libraries(act.drop range-v3)
add_test(test.act.drop act.drop)

add_executable(act.drop_while drop_while.cpp)
target_link_libraries(act.drop_while range-v3)
add_test(test.act.drop_while act.drop_while)

add_executable(act.insert insert.cpp)
target_link_libraries(act.insert range-v3)
add_test(test.act.insert act.insert)

add_executable(act.join join.cpp)
target_link_libraries(act.join range-v3)
add_test(test.act.join act.join)

add_executable(act.push_front push_front.cpp)
target_link_libraries(act.push_front range-v3)
add_test(test.act.push_front act.push_front)

add_executable(act.push_back push_back.cpp)
target_link_libraries(act.push_back range-v3)
add_test(test.act.push_back act.push_back)

add_executable(act.remove_if remove_if.cpp)
target_link_libraries(act.remove_if range-v3)
add_test(test.act.remove_if act.remove_if)

add_executable(act.reverse reverse.cpp)
target_link_libraries(act.reverse range-v3)
add_test(test.act.reverse act.reverse)

add_executable(act.shuffle shuffle.cpp)
target_link_libraries(act.shuffle range-v3)
add_test(test.act.shuffle act.shuffle)

add_executable(act.slice slice.cpp)
target_link_libraries(act.slice range-v3)
add_test(test.act.slice act.slice)

add_executable(act.sort sort.cpp)
target_link_libraries(act.sort range-v3)
add_test(test.act.sort act.sort)

add_executable(act.split split.cpp)
target_link_libraries(act.split range-v3)
add_test(test.act.split act.split)

add_executable(act.stable_sort stable_sort.cpp)
target_link_libraries(act.stable_sort range-v3)
add_test(test.act.stable_sort act.stable_sort)

add_executable(act.stride stride.cpp)
target_link_libraries(act.stride range-v3)
add_test(test.act.stride act.stride)

add_executable(act.take take.cpp)
target_link_libraries(act.take range-v3)
add_test(test.act.take act.take)

add_executable(act.take_while take_while.cpp)
target_link_libraries(act.take_while range-v3)
add_test(test.act.take_while act.take_while)

add_executable(act.transform transform.cpp)
target_link_libraries(act.transform range-v3)
add_test(test.act.transform act.transform)

add_executable(act.unique unique.cpp)
target_link_libraries(act.unique range-v3)
add_test(test.act.unique act.unique)
Loading

0 comments on commit 2ff4cf2

Please sign in to comment.