summaryrefslogtreecommitdiffstats
path: root/Tests/CMakeOnly
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2012-10-31 20:32:41 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2012-10-31 20:32:41 (GMT)
commit6df05b93b15eaf6daa0699095e5a250888ef8d79 (patch)
tree5bde9c59d7a6158ac5ada42476b4a410e3014eca /Tests/CMakeOnly
parentc3b82f67703f00c89a223043e9e48a6b3e1c4aac (diff)
parent66759eea5e90d4af96fd79e2e9017cb2141f5415 (diff)
downloadCMake-6df05b93b15eaf6daa0699095e5a250888ef8d79.zip
CMake-6df05b93b15eaf6daa0699095e5a250888ef8d79.tar.gz
CMake-6df05b93b15eaf6daa0699095e5a250888ef8d79.tar.bz2
Merge topic 'find_library-NAMES_PER_DIR'
66759ee find_library: Optionally consider all names in each directory 9cb68b1 find_library: Generalize helper macro in test case b64dd76 find_library: Simplify framework search logic 531c71b find_library: Refactor internal name iteration
Diffstat (limited to 'Tests/CMakeOnly')
-rw-r--r--Tests/CMakeOnly/find_library/A/libtestA.a0
-rw-r--r--Tests/CMakeOnly/find_library/B/libtestB.a0
-rw-r--r--Tests/CMakeOnly/find_library/CMakeLists.txt49
3 files changed, 31 insertions, 18 deletions
diff --git a/Tests/CMakeOnly/find_library/A/libtestA.a b/Tests/CMakeOnly/find_library/A/libtestA.a
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/CMakeOnly/find_library/A/libtestA.a
diff --git a/Tests/CMakeOnly/find_library/B/libtestB.a b/Tests/CMakeOnly/find_library/B/libtestB.a
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/CMakeOnly/find_library/B/libtestB.a
diff --git a/Tests/CMakeOnly/find_library/CMakeLists.txt b/Tests/CMakeOnly/find_library/CMakeLists.txt
index 08f9331..2d4ecaf 100644
--- a/Tests/CMakeOnly/find_library/CMakeLists.txt
+++ b/Tests/CMakeOnly/find_library/CMakeLists.txt
@@ -3,34 +3,34 @@ project(FindLibraryTest NONE)
set(CMAKE_FIND_DEBUG_MODE 1)
-macro(test_find_library expected)
- get_filename_component(dir ${expected} PATH)
- get_filename_component(name ${expected} NAME)
- string(REGEX REPLACE "lib/?64" "lib" dir "${dir}")
+macro(test_find_library desc expected)
unset(LIB CACHE)
- find_library(LIB
- NAMES ${name}
- PATHS ${CMAKE_CURRENT_SOURCE_DIR}/${dir}
- NO_DEFAULT_PATH
- )
+ find_library(LIB ${ARGN} NO_DEFAULT_PATH)
if(LIB)
# Convert to relative path for comparison to expected location.
file(RELATIVE_PATH REL_LIB "${CMAKE_CURRENT_SOURCE_DIR}" "${LIB}")
- # Debugging output.
- if(CMAKE_FIND_DEBUG_MODE)
- message(STATUS "Library ${expected} searched as ${dir}, found as [${REL_LIB}].")
- endif()
-
# Check and report failure.
if(NOT "${REL_LIB}" STREQUAL "${expected}")
- message(SEND_ERROR "Library ${l} should have been [${expected}] but was [${REL_LIB}]")
+ message(SEND_ERROR "Library ${expected} found as [${REL_LIB}]${desc}")
+ elseif(CMAKE_FIND_DEBUG_MODE)
+ message(STATUS "Library ${expected} found as [${REL_LIB}]${desc}")
endif()
else()
- message(SEND_ERROR "Library ${expected} searched as ${dir}, NOT FOUND!")
+ message(SEND_ERROR "Library ${expected} NOT FOUND${desc}")
endif()
endmacro()
+macro(test_find_library_subst expected)
+ get_filename_component(dir ${expected} PATH)
+ get_filename_component(name ${expected} NAME)
+ string(REGEX REPLACE "lib/?64" "lib" dir "${dir}")
+ test_find_library(", searched as ${dir}" "${expected}"
+ NAMES ${name}
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/${dir}
+ )
+endmacro()
+
set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
@@ -44,7 +44,7 @@ foreach(lib
lib/libtest3.a
lib/libtest3.a
)
- test_find_library(${lib})
+ test_find_library_subst(${lib})
endforeach()
set(CMAKE_SIZEOF_VOID_P 8)
@@ -57,5 +57,18 @@ foreach(lib64
lib64/A/libtest1.a
lib64/libtest1.a
)
- test_find_library(${lib64})
+ test_find_library_subst(${lib64})
endforeach()
+
+test_find_library("" A/libtestA.a
+ NAMES testA testB
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A ${CMAKE_CURRENT_SOURCE_DIR}/B
+ )
+test_find_library("" B/libtestB.a
+ NAMES testB testA
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A ${CMAKE_CURRENT_SOURCE_DIR}/B
+ )
+test_find_library("" A/libtestA.a
+ NAMES testB testA NAMES_PER_DIR
+ PATHS ${CMAKE_CURRENT_SOURCE_DIR}/A ${CMAKE_CURRENT_SOURCE_DIR}/B
+ )