parent
39fa526e1d
commit
a4cab8ff9f
Binary file not shown.
After Width: | Height: | Size: 362 B |
Binary file not shown.
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 46 KiB |
@ -0,0 +1,57 @@
|
|||||||
|
set(bindir ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test nonexistent REALPATH & ABSOLUTE resolution
|
||||||
|
#
|
||||||
|
get_filename_component(nonexistent1 ${bindir}/THIS_IS_A_NONEXISTENT_FILE REALPATH)
|
||||||
|
get_filename_component(nonexistent2 ${bindir}/THIS_IS_A_NONEXISTENT_FILE ABSOLUTE)
|
||||||
|
if(NOT nonexistent1 STREQUAL "${bindir}/THIS_IS_A_NONEXISTENT_FILE")
|
||||||
|
message(FATAL_ERROR "REALPATH is not preserving nonexistent files")
|
||||||
|
endif()
|
||||||
|
if(NOT nonexistent2 STREQUAL "${bindir}/THIS_IS_A_NONEXISTENT_FILE")
|
||||||
|
message(FATAL_ERROR "ABSOLUTE is not preserving nonexistent files")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test symbolic link resolution
|
||||||
|
#
|
||||||
|
if(UNIX)
|
||||||
|
# file1 => file2 => file3 (real)
|
||||||
|
file(WRITE ${bindir}/file3 "test file")
|
||||||
|
|
||||||
|
find_program(LN NAMES "ln")
|
||||||
|
if(LN)
|
||||||
|
# Create symlinks using "ln -s"
|
||||||
|
if(NOT EXISTS ${bindir}/file2)
|
||||||
|
execute_process(COMMAND ${LN} "-s" "${bindir}/file3" "${bindir}/file2")
|
||||||
|
endif()
|
||||||
|
if(NOT EXISTS ${bindir}/file1)
|
||||||
|
execute_process(COMMAND ${LN} "-s" "${bindir}/file2" "${bindir}/file1")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_filename_component(file1 ${bindir}/file1 REALPATH)
|
||||||
|
get_filename_component(file2 ${bindir}/file2 REALPATH)
|
||||||
|
get_filename_component(file3 ${bindir}/file3 REALPATH)
|
||||||
|
|
||||||
|
if(NOT file3 STREQUAL "${bindir}/file3")
|
||||||
|
message(FATAL_ERROR "CMake fails resolving REALPATH file file3")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT file2 STREQUAL "${bindir}/file3")
|
||||||
|
message(FATAL_ERROR "CMake fails resolving simple symlink")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT file1 STREQUAL "${bindir}/file3")
|
||||||
|
message(FATAL_ERROR "CMake fails resolving double symlink")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# cleanup
|
||||||
|
file(REMOVE ${bindir}/file1)
|
||||||
|
file(REMOVE ${bindir}/file2)
|
||||||
|
if(EXISTS file1 OR EXISTS file2)
|
||||||
|
message(FATAL_ERROR "removal of file1 or file2 failed")
|
||||||
|
endif()
|
||||||
|
endif(LN)
|
||||||
|
|
||||||
|
file(REMOVE ${bindir}/file3)
|
||||||
|
endif()
|
@ -0,0 +1,69 @@
|
|||||||
|
# Import targets from the exported build tree.
|
||||||
|
include(${Import_BINARY_DIR}/../Export/ExportBuildTree.cmake)
|
||||||
|
|
||||||
|
# Import targets from the exported install tree.
|
||||||
|
include(${CMAKE_INSTALL_PREFIX}/lib/exp/exp.cmake)
|
||||||
|
|
||||||
|
# Try referencing an executable imported from the install tree.
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${Import_BINARY_DIR}/exp_generated.c
|
||||||
|
COMMAND exp_testExe1 ${Import_BINARY_DIR}/exp_generated.c
|
||||||
|
DEPENDS exp_testExe1
|
||||||
|
)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${Import_BINARY_DIR}/exp_generated3.c
|
||||||
|
COMMAND exp_testExe3 ${Import_BINARY_DIR}/exp_generated3.c
|
||||||
|
DEPENDS exp_testExe3
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(imp_testExe1
|
||||||
|
imp_testExe1.c
|
||||||
|
${Import_BINARY_DIR}/exp_generated.c
|
||||||
|
${Import_BINARY_DIR}/exp_generated3.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# Try linking to a library imported from the install tree.
|
||||||
|
target_link_libraries(imp_testExe1 exp_testLib2 exp_testLib3 exp_testLib4)
|
||||||
|
|
||||||
|
# Try building a plugin to an executable imported from the install tree.
|
||||||
|
add_library(imp_mod1 MODULE imp_mod1.c)
|
||||||
|
target_link_libraries(imp_mod1 exp_testExe2)
|
||||||
|
|
||||||
|
# Try referencing an executable imported from the build tree.
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${Import_BINARY_DIR}/bld_generated.c
|
||||||
|
COMMAND bld_testExe1 ${Import_BINARY_DIR}/bld_generated.c
|
||||||
|
DEPENDS bld_testExe1
|
||||||
|
)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${Import_BINARY_DIR}/bld_generated3.c
|
||||||
|
COMMAND bld_testExe3 ${Import_BINARY_DIR}/bld_generated3.c
|
||||||
|
DEPENDS bld_testExe3
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(imp_testExe1b
|
||||||
|
imp_testExe1.c
|
||||||
|
${Import_BINARY_DIR}/bld_generated.c
|
||||||
|
${Import_BINARY_DIR}/bld_generated3.c
|
||||||
|
)
|
||||||
|
|
||||||
|
# Try linking to a library imported from the build tree.
|
||||||
|
target_link_libraries(imp_testExe1b bld_testLib2 bld_testLib3 bld_testLib4)
|
||||||
|
|
||||||
|
# Try building a plugin to an executable imported from the build tree.
|
||||||
|
add_library(imp_mod1b MODULE imp_mod1.c)
|
||||||
|
target_link_libraries(imp_mod1b bld_testExe2)
|
||||||
|
|
||||||
|
# Export/CMakeLists.txt pretends the RelWithDebInfo (as well as Debug)
|
||||||
|
# configuration should link to debug libs.
|
||||||
|
foreach(c DEBUG RELWITHDEBINFO)
|
||||||
|
set_property(TARGET imp_testExe1 PROPERTY COMPILE_DEFINITIONS_${c} EXE_DBG)
|
||||||
|
set_property(TARGET imp_testExe1b PROPERTY COMPILE_DEFINITIONS_${c} EXE_DBG)
|
||||||
|
endforeach(c)
|
||||||
|
|
||||||
|
# Create a library to be linked by another directory in this project
|
||||||
|
# to test transitive linking to otherwise invisible imported targets.
|
||||||
|
add_library(imp_lib1 STATIC imp_lib1.c)
|
||||||
|
target_link_libraries(imp_lib1 exp_testLib2)
|
||||||
|
add_library(imp_lib1b STATIC imp_lib1.c)
|
||||||
|
target_link_libraries(imp_lib1b bld_testLib2)
|
@ -0,0 +1,6 @@
|
|||||||
|
extern int testLib2(void);
|
||||||
|
|
||||||
|
int imp_lib1(void)
|
||||||
|
{
|
||||||
|
return testLib2();
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
extern int imp_lib1(void);
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
return imp_lib1();
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
#ifdef BAR
|
||||||
|
PRINT * , 'BAR was defined via ADD_DEFINITIONS'
|
||||||
|
#else
|
||||||
|
PRINT *, 'If you can read this something went wrong'
|
||||||
|
#endif
|
@ -0,0 +1,10 @@
|
|||||||
|
GET_CURRENT_FILE(current_file)
|
||||||
|
IF(NOT "${current_file}" STREQUAL "${CMAKE_CURRENT_LIST_FILE}")
|
||||||
|
MESSAGE(FATAL_ERROR
|
||||||
|
"Macro file context is broken. Expected:\n"
|
||||||
|
" ${CMAKE_CURRENT_LIST_FILE}\n"
|
||||||
|
"but got:\n"
|
||||||
|
" ${current_file}\n"
|
||||||
|
"from the macro."
|
||||||
|
)
|
||||||
|
ENDIF(NOT "${current_file}" STREQUAL "${CMAKE_CURRENT_LIST_FILE}")
|
Loading…
Reference in new issue