1# Copyright (c) Facebook, Inc. and its affiliates. 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15enable_testing() 16include(GoogleTest) 17set(THREADS_PREFER_PTHREAD_FLAG ON) 18find_package(Threads REQUIRED) 19 20set(TEST_COMPILE_OPTIONS 21 "${FBJNI_COMPILE_OPTIONS}" 22 -DFBJNI_DEBUG_REFS 23 -UNDEBUG 24) 25 26# Set this globally for all test libraries. It also seems to affect importing. 27set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) 28 29add_library(inter_dso_exception_test_1 SHARED 30 inter_dso_exception_test_1/Test.cpp 31) 32target_compile_options(inter_dso_exception_test_1 PRIVATE ${TEST_COMPILE_OPTIONS}) 33target_link_libraries(inter_dso_exception_test_1 34 fbjni 35) 36 37add_library(inter_dso_exception_test_2 SHARED 38 inter_dso_exception_test_2/Test.cpp 39) 40target_compile_options(inter_dso_exception_test_2 PRIVATE ${TEST_COMPILE_OPTIONS}) 41target_include_directories(inter_dso_exception_test_2 PUBLIC 42 "${CMAKE_CURRENT_SOURCE_DIR}" 43) 44target_link_libraries(inter_dso_exception_test_2 45 fbjni 46 inter_dso_exception_test_1 47) 48 49add_library(no_rtti SHARED 50 no_rtti.cpp 51) 52target_compile_options(no_rtti PRIVATE ${TEST_COMPILE_OPTIONS}) 53target_link_libraries(no_rtti 54 fbjni 55) 56 57add_library(fbjni-tests SHARED 58 byte_buffer_tests.cpp 59 fbjni_onload.cpp 60 fbjni_tests.cpp 61 hybrid_tests.cpp 62 iterator_tests.cpp 63 primitive_array_tests.cpp 64 readable_byte_channel_tests.cpp 65) 66target_compile_options(fbjni-tests PRIVATE ${TEST_COMPILE_OPTIONS}) 67target_link_libraries(fbjni-tests 68 fbjni 69 inter_dso_exception_test_1 70 inter_dso_exception_test_2 71 no_rtti 72) 73 74add_library(doc_tests SHARED 75 doc_tests.cpp 76) 77target_compile_options(doc_tests PRIVATE ${TEST_COMPILE_OPTIONS}) 78target_link_libraries(doc_tests 79 fbjni 80) 81 82add_executable(modified_utf8_test 83 modified_utf8_test.cpp 84) 85target_compile_options(modified_utf8_test PRIVATE ${TEST_COMPILE_OPTIONS}) 86target_link_libraries(modified_utf8_test 87 fbjni 88 gtest 89 Threads::Threads 90 ${CMAKE_DL_LIBS} 91) 92gtest_add_tests(TARGET modified_utf8_test) 93 94add_executable(utf16toUTF8_test 95 utf16toUTF8_test.cpp 96) 97target_compile_options(utf16toUTF8_test PRIVATE ${TEST_COMPILE_OPTIONS}) 98target_link_libraries(utf16toUTF8_test 99 fbjni 100 gtest 101 Threads::Threads 102 ${CMAKE_DL_LIBS} 103) 104gtest_add_tests(TARGET utf16toUTF8_test) 105