mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-05 05:04:27 +02:00
test: standalone public headers tests added
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
cmake_minimum_required(VERSION 3.19)
|
||||
project(mp-units-dev LANGUAGES CXX)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||
@@ -71,3 +71,43 @@ add_subdirectory(docs)
|
||||
# add unit tests
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
|
||||
function(get_target_linked_targets target targets_out)
|
||||
get_target_property(linked_libs ${target} INTERFACE_LINK_LIBRARIES)
|
||||
foreach(linked_lib ${linked_libs})
|
||||
if(NOT linked_lib IN_LIST targets)
|
||||
if(TARGET ${linked_lib})
|
||||
get_target_linked_targets(${linked_lib} child_targets)
|
||||
list(APPEND targets ${linked_lib} ${child_targets})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
list(REMOVE_DUPLICATES targets)
|
||||
list(REMOVE_DUPLICATES link_libs)
|
||||
set(${targets_out} ${targets} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(get_target_sources target paths_out)
|
||||
get_target_linked_targets(${target} targets)
|
||||
list(APPEND targets ${target})
|
||||
|
||||
foreach(t ${targets})
|
||||
get_target_property(sources ${t} SOURCES)
|
||||
if(sources)
|
||||
get_target_property(source_dir ${t} SOURCE_DIR)
|
||||
foreach(f ${sources})
|
||||
file(REAL_PATH "${f}" path BASE_DIRECTORY "${source_dir}")
|
||||
list(APPEND paths "${path}")
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(${paths_out} ${paths} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# tests for standalone headers
|
||||
include(TestHeaders)
|
||||
get_target_sources(mp-units::mp-units sources)
|
||||
add_header_test(test_headers HEADERS ${sources})
|
||||
target_link_libraries(test_headers PRIVATE mp-units::mp-units)
|
||||
|
Reference in New Issue
Block a user