summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Gelas <arnaud.gelas@sensefly.com>2019-10-16 10:06:26 +0200
committerAndreas Schneider <asn@cryptomilk.org>2019-10-22 09:09:06 +0200
commit1a41f98a6ba0fedcb6338396b27bea1ecf4a3998 (patch)
tree99b9a234d81a76fd768b6ce38e50a9db588ce1e9
parent8e60ec80b6d721772d933fe9a09624366bb343e8 (diff)
downloadcmocka-1a41f98a6ba0fedcb6338396b27bea1ecf4a3998.tar.gz
cmocka-1a41f98a6ba0fedcb6338396b27bea1ecf4a3998.tar.xz
cmocka-1a41f98a6ba0fedcb6338396b27bea1ecf4a3998.zip
cmake: Fix usage of cmocka with build tree
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--CMakeLists.txt7
-rw-r--r--cmocka-build-tree-settings.cmake.in4
-rw-r--r--cmocka-config.cmake.in8
3 files changed, 13 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index da3aa68..b3e9193 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -82,6 +82,11 @@ else()
set(CMOCKA_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
endif()
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmocka-build-tree-settings.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/cmocka-build-tree-settings.cmake
+ @ONLY
+)
+
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE INTERNAL "")
set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} CACHE INTERNAL "")
configure_package_config_file(${PROJECT_NAME}-config.cmake.in
@@ -89,7 +94,7 @@ configure_package_config_file(${PROJECT_NAME}-config.cmake.in
PATH_VARS
INCLUDE_INSTALL_DIR LIB_INSTALL_DIR
INSTALL_DESTINATION
- ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
+ ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/${PROJECT_NAME})
write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake
COMPATIBILITY
diff --git a/cmocka-build-tree-settings.cmake.in b/cmocka-build-tree-settings.cmake.in
index eb1f29e..d0883b1 100644
--- a/cmocka-build-tree-settings.cmake.in
+++ b/cmocka-build-tree-settings.cmake.in
@@ -1 +1,3 @@
-set(CMOCKA_INLUDE_DIR @PROJECT_SOURCE_DIR@/include)
+set_and_check(CMOCKA_INLUDE_DIR @PROJECT_SOURCE_DIR@/include)
+set_and_check(CMOCKA_LIBRARY @PROJECT_BINARY_DIR@/src/@CMOCKA_LIBRARY_NAME@)
+set_and_check(CMOCKA_LIBRARIES @PROJECT_BINARY_DIR@/src/@CMOCKA_LIBRARY_NAME@)
diff --git a/cmocka-config.cmake.in b/cmocka-config.cmake.in
index 0890d71..a3af5d7 100644
--- a/cmocka-config.cmake.in
+++ b/cmocka-config.cmake.in
@@ -6,10 +6,10 @@ if (EXISTS "${CMOCKA_CMAKE_DIR}/CMakeCache.txt")
# In build tree
include(${CMOCKA_CMAKE_DIR}/cmocka-build-tree-settings.cmake)
else()
- set(CMOCKA_INCLUDE_DIR @PACKAGE_INCLUDE_INSTALL_DIR@)
-endif()
+ set_and_check(CMOCKA_INCLUDE_DIR @PACKAGE_INCLUDE_INSTALL_DIR@)
-set(CMOCKA_LIBRARY @PACKAGE_LIB_INSTALL_DIR@/@CMOCKA_LIBRARY_NAME@)
-set(CMOCKA_LIBRARIES @PACKAGE_LIB_INSTALL_DIR@/@CMOCKA_LIBRARY_NAME@)
+ set_and_check(CMOCKA_LIBRARY @PACKAGE_LIB_INSTALL_DIR@/@CMOCKA_LIBRARY_NAME@)
+ set_and_check(CMOCKA_LIBRARIES @PACKAGE_LIB_INSTALL_DIR@/@CMOCKA_LIBRARY_NAME@)
+endif()
mark_as_advanced(CMOCKA_LIBRARY CMOCKA_INCLUDE_DIR)