mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
CMake: allow ctest to be run without having to install zint or
manually set LD_LIBRARY_PATH and PATH (ticket #279, props Alexey Dokuchaev)
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
# Copyright (C) 2021 Robin Stuart <rstuart114@gmail.com>
|
||||
# Copyright (C) 2021-23 Robin Stuart <rstuart114@gmail.com>
|
||||
# Adapted from qrencode/tests/CMakeLists.txt
|
||||
# Copyright (C) 2006-2017 Kentaro Fukuchi <kentaro@fukuchi.org>
|
||||
# vim: set ts=4 sw=4 et :
|
||||
@ -9,12 +9,24 @@ macro(zint_add_test test_name test_command)
|
||||
add_executable(${test_command} ${test_command}.c)
|
||||
target_link_libraries(${test_command} testcommon ${ADDITIONAL_LIBS})
|
||||
add_test(${test_name} ${test_command})
|
||||
set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
if(MSVC)
|
||||
set_tests_properties(${test_name} PROPERTIES ENVIRONMENT
|
||||
"CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR};PATH=${CMAKE_BINARY_DIR}/backend/${CMAKE_BUILD_TYPE}\;${CMAKE_BINARY_DIR}/frontend/${CMAKE_BUILD_TYPE}\;$ENV{PATH}")
|
||||
else()
|
||||
set_tests_properties(${test_name} PROPERTIES ENVIRONMENT
|
||||
"CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR};LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/backend;PATH=${CMAKE_BINARY_DIR}/frontend:$ENV{PATH}")
|
||||
endif()
|
||||
endif()
|
||||
if(ZINT_STATIC)
|
||||
add_executable(${test_command}-static ${test_command}.c)
|
||||
target_link_libraries(${test_command}-static testcommon-static ${ADDITIONAL_LIBS})
|
||||
add_test(${test_name}-static ${test_command}-static)
|
||||
set_tests_properties(${test_name}-static PROPERTIES ENVIRONMENT "CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
if(MSVC)
|
||||
set_tests_properties(${test_name}-static PROPERTIES ENVIRONMENT
|
||||
"CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR};PATH=${CMAKE_BINARY_DIR}/backend/${CMAKE_BUILD_TYPE}\;${CMAKE_BINARY_DIR}/frontend/${CMAKE_BUILD_TYPE}\;$ENV{PATH}")
|
||||
else()
|
||||
set_tests_properties(${test_name}-static PROPERTIES ENVIRONMENT
|
||||
"CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR};LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/backend;PATH=${CMAKE_BINARY_DIR}/frontend:$ENV{PATH}")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
Reference in New Issue
Block a user