summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-10-01 18:05:11 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2012-10-01 18:05:11 (GMT)
commit7dce31f3d03e2202ad54d8b6eb8ab00bce8bbe00 (patch)
tree88ded98011b9f5b12c3fce3a600d2d0da4ff8846 /Tests
parent7fc4d8138404f5855630377699a8632d7aa32dcf (diff)
parent2ccca05fade0014dbfbce906b20ab4073ecd8d9c (diff)
downloadCMake-7dce31f3d03e2202ad54d8b6eb8ab00bce8bbe00.zip
CMake-7dce31f3d03e2202ad54d8b6eb8ab00bce8bbe00.tar.gz
CMake-7dce31f3d03e2202ad54d8b6eb8ab00bce8bbe00.tar.bz2
Merge topic 'vs-pdb-output'
2ccca05 Run PDBDirectoryAndName test on MSVC and Intel efc83b3 Document that PDB_(NAME|OUTPUT_DIRECTORY) are ignored for VS 6 b294457 Verify that PDB_(NAME|OUTPUT_DIRECTORY) are honored in test 3f60dbf Add PDB_OUTPUT_DIRECTORY and PDB_NAME target properties (#10830)
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeLists.txt1
-rw-r--r--Tests/PDBDirectoryAndName/CMakeLists.txt79
-rw-r--r--Tests/PDBDirectoryAndName/check_pdbs.cmake10
-rw-r--r--Tests/PDBDirectoryAndName/myexe.c5
-rw-r--r--Tests/PDBDirectoryAndName/myexe2.c3
-rw-r--r--Tests/PDBDirectoryAndName/mylibA.c1
-rw-r--r--Tests/PDBDirectoryAndName/mylibB.c1
-rw-r--r--Tests/PDBDirectoryAndName/mylibC.c1
-rw-r--r--Tests/PDBDirectoryAndName/mylibD.c1
9 files changed, 102 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index e03b926..ae69ce8 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1254,6 +1254,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
if(CMAKE_TEST_MSVC)
ADD_TEST_MACRO(ForceInclude foo)
+ ADD_TEST_MACRO(PDBDirectoryAndName myexe)
ADD_TEST_MACRO(PrecompiledHeader foo)
endif()
if(CMAKE_TEST_MSVC OR
diff --git a/Tests/PDBDirectoryAndName/CMakeLists.txt b/Tests/PDBDirectoryAndName/CMakeLists.txt
new file mode 100644
index 0000000..bc2f013
--- /dev/null
+++ b/Tests/PDBDirectoryAndName/CMakeLists.txt
@@ -0,0 +1,79 @@
+cmake_minimum_required(VERSION 2.8)
+project(PDBDirectoryAndName C)
+
+# Make sure the proper compiler is in use.
+if(NOT MSVC AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$")
+ message(FATAL_ERROR "The PDBDirectoryAndName test works only with MSVC or Intel")
+endif()
+
+set(my_targets "")
+
+add_library(mylibA SHARED mylibA.c)
+set_target_properties(mylibA PROPERTIES
+ PDB_NAME "mylibA_Special"
+ PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibA_PDB"
+)
+list(APPEND my_targets mylibA)
+
+add_library(mylibB STATIC mylibB.c)
+set_target_properties(mylibB PROPERTIES
+ PDB_NAME "mylibB_Special"
+ PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibB_PDB"
+)
+list(APPEND my_targets mylibB)
+
+add_library(mylibC SHARED mylibC.c)
+set_target_properties(mylibC PROPERTIES
+ PDB_NAME "mylibC_Special"
+)
+list(APPEND my_targets mylibC)
+
+add_library(mylibD STATIC mylibD.c)
+set_target_properties(mylibD PROPERTIES
+ PDB_NAME "mylibD_Special"
+)
+list(APPEND my_targets mylibD)
+
+add_executable(myexe myexe.c)
+set_target_properties(myexe PROPERTIES
+ PDB_NAME "myexe_Special"
+ PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/myexe_PDB"
+)
+list(APPEND my_targets myexe)
+
+target_link_libraries(myexe mylibA mylibB mylibC mylibD)
+
+add_executable(myexe2 myexe2.c)
+set_target_properties(myexe2 PROPERTIES
+ PDB_NAME "myexe2_Special"
+)
+list(APPEND my_targets myexe2)
+
+target_link_libraries(myexe2 mylibA mylibD)
+
+#-----------------------------------------------------------------------------
+# Check that PDB files actually appear where expected.
+
+# The PDB_NAME and PDB_OUTPUT_DIRECTORY options do not work in VS 6.
+if("${CMAKE_GENERATOR}" MATCHES "Visual Studio 6")
+ return()
+endif()
+# PDB output not fully implemented for Intel
+if("${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$")
+ return()
+endif()
+
+set(pdbs "")
+foreach(t ${my_targets})
+ get_property(pdb_name TARGET ${t} PROPERTY PDB_NAME)
+ get_property(pdb_dir TARGET ${t} PROPERTY PDB_OUTPUT_DIRECTORY)
+ if(NOT pdb_dir)
+ set(pdb_dir ${CMAKE_CURRENT_BINARY_DIR})
+ endif()
+ list(APPEND pdbs ${pdb_dir}/${CMAKE_CFG_INTDIR}/${pdb_name}.pdb)
+endforeach()
+add_custom_target(check_pdbs ALL VERBATIM
+ COMMAND ${CMAKE_COMMAND} -Dconfig=$<CONFIGURATION> "-Dpdbs=${pdbs}"
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/check_pdbs.cmake
+ )
+add_dependencies(check_pdbs ${my_targets})
diff --git a/Tests/PDBDirectoryAndName/check_pdbs.cmake b/Tests/PDBDirectoryAndName/check_pdbs.cmake
new file mode 100644
index 0000000..89cdb3c
--- /dev/null
+++ b/Tests/PDBDirectoryAndName/check_pdbs.cmake
@@ -0,0 +1,10 @@
+if(NOT "${config}" MATCHES "[Dd][Ee][Bb]")
+ return()
+endif()
+foreach(pdb ${pdbs})
+ if(EXISTS "${pdb}")
+ message(STATUS "PDB Exists: ${pdb}")
+ else()
+ message(SEND_ERROR "PDB MISSING: ${pdb}")
+ endif()
+endforeach()
diff --git a/Tests/PDBDirectoryAndName/myexe.c b/Tests/PDBDirectoryAndName/myexe.c
new file mode 100644
index 0000000..c6d9065
--- /dev/null
+++ b/Tests/PDBDirectoryAndName/myexe.c
@@ -0,0 +1,5 @@
+extern int mylibA();
+extern int mylibB();
+extern int mylibC();
+extern int mylibD();
+int main() { return mylibA() + mylibB() + mylibC() + mylibD(); }
diff --git a/Tests/PDBDirectoryAndName/myexe2.c b/Tests/PDBDirectoryAndName/myexe2.c
new file mode 100644
index 0000000..75b39cd
--- /dev/null
+++ b/Tests/PDBDirectoryAndName/myexe2.c
@@ -0,0 +1,3 @@
+extern int mylibA();
+extern int mylibD();
+int main() { return mylibA() + mylibD(); }
diff --git a/Tests/PDBDirectoryAndName/mylibA.c b/Tests/PDBDirectoryAndName/mylibA.c
new file mode 100644
index 0000000..f4c553f
--- /dev/null
+++ b/Tests/PDBDirectoryAndName/mylibA.c
@@ -0,0 +1 @@
+__declspec(dllexport) int mylibA() { return 1; }
diff --git a/Tests/PDBDirectoryAndName/mylibB.c b/Tests/PDBDirectoryAndName/mylibB.c
new file mode 100644
index 0000000..2040c67
--- /dev/null
+++ b/Tests/PDBDirectoryAndName/mylibB.c
@@ -0,0 +1 @@
+int mylibB() { return -1; }
diff --git a/Tests/PDBDirectoryAndName/mylibC.c b/Tests/PDBDirectoryAndName/mylibC.c
new file mode 100644
index 0000000..adf7c70
--- /dev/null
+++ b/Tests/PDBDirectoryAndName/mylibC.c
@@ -0,0 +1 @@
+__declspec(dllexport) int mylibC() { return 1; }
diff --git a/Tests/PDBDirectoryAndName/mylibD.c b/Tests/PDBDirectoryAndName/mylibD.c
new file mode 100644
index 0000000..efa8a82
--- /dev/null
+++ b/Tests/PDBDirectoryAndName/mylibD.c
@@ -0,0 +1 @@
+int mylibD() { return -1; }