58 lines
2.0 KiB
CMake
58 lines
2.0 KiB
CMake
#[=======================================================================[.rst:
|
||
myx_add_sapr_test
|
||
-----------------
|
||
|
||
Вспомогательная функция для создания теста САПР::
|
||
|
||
myx_add_sapr_block(TARGET_NAME FILE_NAME)
|
||
|
||
Обязательные параметры: `TARGET_NAME` - имя теста, `FILE_NAME` - имя файла.
|
||
|
||
#]=======================================================================]
|
||
|
||
include_guard(GLOBAL)
|
||
|
||
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
||
set(MYX_CMAKE_LIB_DIR_BACKPORT "${CMAKE_CURRENT_LIST_DIR}")
|
||
endif()
|
||
|
||
function(myx_add_sapr_test TARGET_NAME FILE_NAME)
|
||
if(${CMAKE_VERSION} VERSION_LESS "3.17.0")
|
||
set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYX_CMAKE_LIB_DIR_BACKPORT})
|
||
endif()
|
||
|
||
add_executable(${TARGET_NAME} ${FILE_NAME})
|
||
|
||
target_include_directories(${TARGET_NAME}
|
||
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/thirdparty/sapr>)
|
||
|
||
find_package(GTest)
|
||
if(GTest_FOUND)
|
||
target_link_libraries(${TARGET_NAME} PRIVATE GTest::GTest GTest::Main)
|
||
else()
|
||
add_subdirectory(/usr/src/googletest/googletest ${CMAKE_BINARY_DIR}/gtest)
|
||
target_link_libraries(${TARGET_NAME} PRIVATE gtest gtest_main)
|
||
endif()
|
||
|
||
if(${CMAKE_VERSION} VERSION_LESS "3.12.0")
|
||
find_package(PythonLibs REQUIRED)
|
||
find_package(PythonInterp REQUIRED)
|
||
target_include_directories(${TARGET_NAME} PRIVATE ${PYTHON_INCLUDE_DIRS})
|
||
target_link_libraries(${TARGET_NAME} PRIVATE ${PYTHON_LIBRARIES})
|
||
else()
|
||
find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
|
||
target_include_directories(${TARGET_NAME} PRIVATE ${Python3_INCLUDE_DIRS})
|
||
endif()
|
||
|
||
find_package(pybind11 REQUIRED)
|
||
target_include_directories(${TARGET_NAME} PRIVATE ${pybind11_INCLUDE_DIR})
|
||
if(pybind11_VERSION VERSION_LESS "2.5.0")
|
||
target_link_libraries(${TARGET_NAME} PRIVATE pybind11::module)
|
||
else()
|
||
target_link_libraries(${TARGET_NAME} PRIVATE pybind11::headers pybind11::pybind11)
|
||
endif()
|
||
|
||
add_test(NAME ${TARGET_NAME} COMMAND ${TARGET_NAME})
|
||
endfunction()
|
||
|