summaryrefslogtreecommitdiff
path: root/Tests/BuildDepends
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/BuildDepends')
-rw-r--r--Tests/BuildDepends/CMakeLists.txt34
-rw-r--r--Tests/BuildDepends/Project/CMakeLists.txt18
-rw-r--r--Tests/BuildDepends/Project/dep_custom2.cxx2
-rw-r--r--Tests/BuildDepends/Project/link_depends_no_shared_check.cmake7
-rw-r--r--Tests/BuildDepends/Project/link_depends_no_shared_exe.c9
-rw-r--r--Tests/BuildDepends/Project/link_depends_no_shared_lib.c8
6 files changed, 77 insertions, 1 deletions
diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt
index 2a70b6eae..27927512a 100644
--- a/Tests/BuildDepends/CMakeLists.txt
+++ b/Tests/BuildDepends/CMakeLists.txt
@@ -60,6 +60,12 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx
file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_tgt.hxx
"static const char* zot_macro_tgt = \"zot_macro_tgt\";\n")
+file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_lib.h
+ "#define link_depends_no_shared_lib_value 1\n")
+file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_exe.h
+ "#define link_depends_no_shared_exe_value 0\n")
+set(link_depends_no_shared_check_txt ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_check.txt)
+
help_xcode_depends()
message("Building project first time")
@@ -125,6 +131,19 @@ else()
message(SEND_ERROR "Project did not initially build properly: ${out}")
endif()
+if(EXISTS "${link_depends_no_shared_check_txt}")
+ file(STRINGS "${link_depends_no_shared_check_txt}" link_depends_no_shared_check LIMIT_COUNT 1)
+ if("${link_depends_no_shared_check}" STREQUAL "1")
+ message(STATUS "link_depends_no_shared_exe is newer than link_depends_no_shared_lib as expected.")
+ else()
+ message(SEND_ERROR "Project did not initially build properly: "
+ "link_depends_no_shared_exe is older than link_depends_no_shared_lib.")
+ endif()
+else()
+ message(SEND_ERROR "Project did not initially build properly: "
+ "Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.")
+endif()
+
message("Waiting 3 seconds...")
# any additional argument will cause ${bar} to wait forever
execute_process(COMMAND ${bar} -infinite TIMEOUT 3 OUTPUT_VARIABLE out)
@@ -141,6 +160,9 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx
file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_tgt.hxx
"static const char* zot_macro_tgt = \"zot_macro_tgt changed\";\n")
+file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_lib.h
+ "#define link_depends_no_shared_lib_value 0\n")
+
if(TEST_LINK_DEPENDS)
file(WRITE ${TEST_LINK_DEPENDS} "2")
endif()
@@ -219,3 +241,15 @@ is not newer than dependency
")
endif()
endif()
+
+if(EXISTS "${link_depends_no_shared_check_txt}")
+ file(STRINGS "${link_depends_no_shared_check_txt}" link_depends_no_shared_check LIMIT_COUNT 1)
+ if("${link_depends_no_shared_check}" STREQUAL "0")
+ message(STATUS "link_depends_no_shared_exe is older than link_depends_no_shared_lib as expected.")
+ else()
+ message(SEND_ERROR "Project did not rebuild properly: link_depends_no_shared_exe is newer than link_depends_no_shared_lib.")
+ endif()
+else()
+ message(SEND_ERROR "Project did not rebuild properly. "
+ "Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.")
+endif()
diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt
index 01f5f6267..f8a3d1550 100644
--- a/Tests/BuildDepends/Project/CMakeLists.txt
+++ b/Tests/BuildDepends/Project/CMakeLists.txt
@@ -64,7 +64,8 @@ if("${CMAKE_GENERATOR}" MATCHES "Make")
# Test the IMPLICIT_DEPENDS feature.
set(ZOT_DEPENDS IMPLICIT_DEPENDS CXX ${CMAKE_CURRENT_SOURCE_DIR}/dep.cxx)
set(ZOT_CUSTOM_DEP
- IMPLICIT_DEPENDS CXX ${CMAKE_CURRENT_SOURCE_DIR}/dep_custom.cxx)
+ IMPLICIT_DEPENDS CXX ${CMAKE_CURRENT_SOURCE_DIR}/dep_custom.cxx
+ CXX ${CMAKE_CURRENT_SOURCE_DIR}/dep_custom2.cxx )
else()
# No IMPLICIT_DEPENDS...just depend directly.
set(ZOT_DEPENDS DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/zot.hxx.in)
@@ -107,3 +108,18 @@ if(TEST_LINK_DEPENDS)
add_executable(linkdep linkdep.cxx)
set_property(TARGET linkdep PROPERTY LINK_DEPENDS ${TEST_LINK_DEPENDS})
endif()
+
+add_library(link_depends_no_shared_lib SHARED link_depends_no_shared_lib.c
+ ${CMAKE_CURRENT_BINARY_DIR}/link_depends_no_shared_lib.h)
+add_executable(link_depends_no_shared_exe link_depends_no_shared_exe.c
+ ${CMAKE_CURRENT_BINARY_DIR}/link_depends_no_shared_exe.h)
+target_link_libraries(link_depends_no_shared_exe link_depends_no_shared_lib)
+set_property(TARGET link_depends_no_shared_exe PROPERTY LINK_DEPENDS_NO_SHARED 1)
+add_custom_target(link_depends_no_shared_check ALL
+ COMMAND ${CMAKE_COMMAND}
+ -Dlib=$<TARGET_FILE:link_depends_no_shared_lib>
+ -Dexe=$<TARGET_FILE:link_depends_no_shared_exe>
+ -Dout=${CMAKE_CURRENT_BINARY_DIR}/link_depends_no_shared_check.txt
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/link_depends_no_shared_check.cmake
+ )
+add_dependencies(link_depends_no_shared_check link_depends_no_shared_exe)
diff --git a/Tests/BuildDepends/Project/dep_custom2.cxx b/Tests/BuildDepends/Project/dep_custom2.cxx
new file mode 100644
index 000000000..ac9dee120
--- /dev/null
+++ b/Tests/BuildDepends/Project/dep_custom2.cxx
@@ -0,0 +1,2 @@
+#include <zot_custom.hxx.in>
+// some comment
diff --git a/Tests/BuildDepends/Project/link_depends_no_shared_check.cmake b/Tests/BuildDepends/Project/link_depends_no_shared_check.cmake
new file mode 100644
index 000000000..3a611370f
--- /dev/null
+++ b/Tests/BuildDepends/Project/link_depends_no_shared_check.cmake
@@ -0,0 +1,7 @@
+if(NOT EXISTS "${lib}" OR NOT EXISTS "${exe}")
+ file(REMOVE "${out}")
+elseif("${exe}" IS_NEWER_THAN "${lib}")
+ file(WRITE "${out}" "1\n")
+else()
+ file(WRITE "${out}" "0\n")
+endif()
diff --git a/Tests/BuildDepends/Project/link_depends_no_shared_exe.c b/Tests/BuildDepends/Project/link_depends_no_shared_exe.c
new file mode 100644
index 000000000..e9113a21d
--- /dev/null
+++ b/Tests/BuildDepends/Project/link_depends_no_shared_exe.c
@@ -0,0 +1,9 @@
+#include "link_depends_no_shared_exe.h"
+#ifdef _WIN32
+__declspec(dllimport)
+#endif
+int link_depends_no_shared_lib(void);
+int main()
+{
+ return link_depends_no_shared_lib() + link_depends_no_shared_exe_value;
+}
diff --git a/Tests/BuildDepends/Project/link_depends_no_shared_lib.c b/Tests/BuildDepends/Project/link_depends_no_shared_lib.c
new file mode 100644
index 000000000..d2262894b
--- /dev/null
+++ b/Tests/BuildDepends/Project/link_depends_no_shared_lib.c
@@ -0,0 +1,8 @@
+#include "link_depends_no_shared_lib.h"
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int link_depends_no_shared_lib(void)
+{
+ return link_depends_no_shared_lib_value;
+}