File: CMakeLists.txt

package info (click to toggle)
exiv2 0.27.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 54,956 kB
  • sloc: cpp: 80,713; python: 4,360; sh: 1,497; makefile: 320; javascript: 237; awk: 92; ansic: 78; sed: 16
file content (88 lines) | stat: -rw-r--r-- 2,323 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
find_package(GTest REQUIRED)

get_target_property(exiv2lib_SOURCES exiv2lib SOURCES)
get_target_property(exiv2lib_int_SOURCES exiv2lib_int SOURCES)
get_target_property(exiv2lib_COMPILE_DEFINITIONS exiv2lib COMPILE_DEFINITIONS)
get_target_property(exiv2lib_INCLUDE_DIRECTORIES exiv2lib INCLUDE_DIRECTORIES)
get_target_property(exiv2lib_LINK_LIBRARIES exiv2lib LINK_LIBRARIES)

set(unit_tests_exiv2lib_SOURCES)
foreach(source IN LISTS exiv2lib_SOURCES exiv2lib_int_SOURCES)
    if(source MATCHES "\.(c|cpp|h|hpp)$")
        if(source MATCHES ".*/.*")
            list(APPEND unit_tests_exiv2lib_SOURCES "${source}")
        else()
            list(APPEND unit_tests_exiv2lib_SOURCES "../src/${source}")
        endif()
    endif()
endforeach()

add_executable(unit_tests
    mainTestRunner.cpp
    test_DateValue.cpp
    test_TimeValue.cpp
    test_XmpKey.cpp
    test_basicio.cpp
    test_cr2header_int.cpp
    test_enforce.cpp
    test_FileIo.cpp
    test_futils.cpp
    test_helper_functions.cpp
    test_image_int.cpp
    test_safe_op.cpp
    test_slice.cpp
    test_tiffheader.cpp
    test_types.cpp
    gtestwrapper.h
    ${unit_tests_exiv2lib_SOURCES}
)

target_compile_definitions(unit_tests
  PRIVATE
    exiv2lib_STATIC
    TESTDATA_PATH="${PROJECT_SOURCE_DIR}/test/data"
)

if (exiv2lib_COMPILE_DEFINITIONS)
    target_compile_definitions(unit_tests PRIVATE ${exiv2lib_COMPILE_DEFINITIONS})
endif ()

target_include_directories(unit_tests
    PRIVATE
        ${exiv2lib_INCLUDE_DIRECTORIES}
)

#TODO Use GTest::GTest once we upgrade the minimum CMake version required
target_link_libraries(unit_tests
    PRIVATE
        ${exiv2lib_LINK_LIBRARIES}
        ${GTEST_BOTH_LIBRARIES}
)

# ZLIB is used in exiv2lib_int.
if( EXIV2_ENABLE_PNG )
    target_link_libraries(unit_tests PRIVATE ${ZLIB_LIBRARIES} )
endif()

target_include_directories(unit_tests
    PRIVATE
        ${GTEST_INCLUDE_DIRS}
        ${CMAKE_SOURCE_DIR}/src
)

target_compile_definitions(unit_tests
    PRIVATE
        GTEST_LINKED_AS_SHARED_LIBRARY=1
)

set_target_properties(unit_tests PROPERTIES
    COMPILE_FLAGS ${EXTRA_COMPILE_FLAGS}
)

if (USING_CONAN)
    target_compile_definitions(unit_tests PRIVATE ${CONAN_COMPILE_DEFINITIONS_GTEST})
endif()

if (MSVC)
    set_target_properties(unit_tests PROPERTIES LINK_FLAGS "/ignore:4099")
endif()