Hash :
3a6954e0
Author :
Date :
2018-06-07T08:09:07
cmake: Always build libdecoder as static library libdecoder is used only for tests, and implicitly relies on printBinary() function that is not included in the library. This causes it to fail to build as a shared library on systems strict about symbols (Darwin or e.g. Linux with -Wl,-z,defs). Force static library to avoid those problems.
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
add_library(common
common.c common.h)
target_link_libraries(common qrencode)
add_library(rscode
rscode.c rscode.h)
target_link_libraries(rscode common)
macro(MAKE_TEST test_name)
set(ADDITIONAL_LIBS "${ARGN}")
add_executable(${test_name} ${test_name}.c)
target_link_libraries(${test_name} common ${ADDITIONAL_LIBS})
add_test(${test_name} ${test_name})
endmacro(MAKE_TEST)
if(TARGET PNG::PNG)
add_executable(create_frame_pattern create_frame_pattern.c)
target_link_libraries(create_frame_pattern common PNG::PNG)
add_executable(create_mqr_frame_pattern create_mqr_frame_pattern.c)
target_link_libraries(create_mqr_frame_pattern common PNG::PNG)
endif()
if(HAVE_SDL)
add_executable(view_qrcode view_qrcode.c)
target_link_libraries(view_qrcode common)
endif(HAVE_SDL)
if(TARGET Threads::Threads)
add_executable(prof_qrencode prof_qrencode.c)
target_link_libraries(prof_qrencode common Threads::Threads)
add_executable(pthread_qrencode pthread_qrencode.c)
target_link_libraries(pthread_qrencode common Threads::Threads)
endif()
MAKE_TEST(test_bitstream)
MAKE_TEST(test_estimatebit)
MAKE_TEST(test_split)
if(TARGET ICONV::ICONV)
add_library(decoder STATIC
decoder.c decoder.h
datachunk.c datachunk.h
rsecc_decoder.c rsecc_decoder.h)
target_link_libraries(decoder ICONV::ICONV)
MAKE_TEST(test_qrinput decoder)
MAKE_TEST(test_qrspec decoder)
target_compile_definitions(test_qrspec PRIVATE -DSRCDIR="${CMAKE_CURRENT_SOURCE_DIR}/")
MAKE_TEST(test_mqrspec decoder)
MAKE_TEST(test_qrencode decoder)
MAKE_TEST(test_split_urls decoder)
MAKE_TEST(test_monkey decoder)
include(CheckCSourceCompiles)
check_c_source_compiles(
"int main(){
const int w = 1;
char buf[w];
return 0;
}"
FIXED_SIZE_BUFFER_INITIALIZATION)
if(FIXED_SIZE_BUFFER_INITIALIZATION)
MAKE_TEST(test_mask decoder)
MAKE_TEST(test_mmask decoder)
MAKE_TEST(test_rs rscode decoder)
endif()
endif()