diff options
author | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
---|---|---|
committer | Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> | 2023-10-10 14:33:42 +0000 |
commit | af1a266670d040d2f4083ff309d732d648afba2a (patch) | |
tree | 2fc46203448ddcc6f81546d379abfaeb323575e9 /meson/test cases/linuxlike/13 cmake dependency/cmake | |
parent | e02cda008591317b1625707ff8e115a4841aa889 (diff) |
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'meson/test cases/linuxlike/13 cmake dependency/cmake')
-rw-r--r-- | meson/test cases/linuxlike/13 cmake dependency/cmake/FindImportedTarget.cmake | 15 | ||||
-rw-r--r-- | meson/test cases/linuxlike/13 cmake dependency/cmake/FindSomethingLikeZLIB.cmake | 56 |
2 files changed, 71 insertions, 0 deletions
diff --git a/meson/test cases/linuxlike/13 cmake dependency/cmake/FindImportedTarget.cmake b/meson/test cases/linuxlike/13 cmake dependency/cmake/FindImportedTarget.cmake new file mode 100644 index 000000000..753df5bc0 --- /dev/null +++ b/meson/test cases/linuxlike/13 cmake dependency/cmake/FindImportedTarget.cmake @@ -0,0 +1,15 @@ +find_package(ZLIB) + +if(ZLIB_FOUND OR ZLIB_Found) + set(ImportedTarget_FOUND ON) + add_library(mesonTestLibDefs SHARED IMPORTED) + set_property(TARGET mesonTestLibDefs PROPERTY IMPORTED_LOCATION ${ZLIB_LIBRARY}) + set_property(TARGET mesonTestLibDefs PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIR}) + set_property(TARGET mesonTestLibDefs APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS REQUIRED_MESON_FLAG1) + set_property(TARGET mesonTestLibDefs APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>) # Error empty string + set_property(TARGET mesonTestLibDefs APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS REQUIRED_MESON_FLAG2) + set_target_properties(mesonTestLibDefs PROPERTIES IMPORTED_GLOBAL TRUE) + add_library(MesonTest::TestLibDefs ALIAS mesonTestLibDefs) +else() + set(ImportedTarget_FOUND OFF) +endif() diff --git a/meson/test cases/linuxlike/13 cmake dependency/cmake/FindSomethingLikeZLIB.cmake b/meson/test cases/linuxlike/13 cmake dependency/cmake/FindSomethingLikeZLIB.cmake new file mode 100644 index 000000000..483926ce8 --- /dev/null +++ b/meson/test cases/linuxlike/13 cmake dependency/cmake/FindSomethingLikeZLIB.cmake @@ -0,0 +1,56 @@ +find_package(ZLIB) + +include(CMakeFindDependencyMacro) +include(CheckCXXSourceRuns) +include(CheckCSourceRuns) + +# Do something stupid (see https://github.com/mesonbuild/meson/issues/7501) +set("") + +check_cxx_source_runs( +" +#include <iostream> + +using namespace std; + +int main(void) { + cout << \"Hello World\" << endl; + return 0; +} +" +CXX_CODE_RAN +) + +check_c_source_runs( +" +#include <stdio.h> + +int main(void) { + printf(\"Hello World\"); + return 0; +} +" +C_CODE_RAN +) + +if(NOT CXX_CODE_RAN) + message(FATAL_ERROR "Running CXX source code failed") +endif() + +if(NOT C_CODE_RAN) + message(FATAL_ERROR "Running C source code failed") +endif() + +if(NOT SomethingLikeZLIB_FIND_COMPONENTS STREQUAL "required_comp") + message(FATAL_ERROR "Component 'required_comp' was not specified") +endif() + +find_dependency(Threads) + +if(ZLIB_FOUND OR ZLIB_Found) + set(SomethingLikeZLIB_FOUND ON) + set(SomethingLikeZLIB_LIBRARIES ${ZLIB_LIBRARY}) + set(SomethingLikeZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR}) +else() + set(SomethingLikeZLIB_FOUND OFF) +endif() |