set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
endif()
+# Dependencies for all Windows resource files:
+set(W32RES_DEPENDENCIES
+ "${CMAKE_CURRENT_SOURCE_DIR}/src/common/common_w32res.rc"
+ "${CMAKE_CURRENT_SOURCE_DIR}/src/common/w32_application.manifest"
+)
+
# Definitions common to all targets:
add_compile_definitions(
# Package info:
target_sources(liblzma PRIVATE src/liblzma/liblzma_w32res.rc)
set_source_files_properties(src/liblzma/liblzma_w32res.rc PROPERTIES
- OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/common/common_w32res.rc"
+ OBJECT_DEPENDS "${W32RES_DEPENDENCIES}"
)
# Export the public API symbols with __declspec(dllexport).
target_sources("${XZDEC}" PRIVATE "src/xzdec/${XZDEC}_w32res.rc")
set_source_files_properties(
"src/xzdec/${XZDEC}_w32res.rc" PROPERTIES
- OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/common/common_w32res.rc"
+ OBJECT_DEPENDS "${W32RES_DEPENDENCIES}"
)
endif()
# Add the Windows resource file for lzmainfo.exe.
target_sources(lzmainfo PRIVATE src/lzmainfo/lzmainfo_w32res.rc)
set_source_files_properties(src/lzmainfo/lzmainfo_w32res.rc PROPERTIES
- OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/common/common_w32res.rc"
+ OBJECT_DEPENDS "${W32RES_DEPENDENCIES}"
)
endif()
# Add the Windows resource file for xz.exe.
target_sources(xz PRIVATE src/xz/xz_w32res.rc)
set_source_files_properties(src/xz/xz_w32res.rc PROPERTIES
- OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/common/common_w32res.rc"
+ OBJECT_DEPENDS "${W32RES_DEPENDENCIES}"
)
endif()
tests.cmake \
tuktest.h \
tests.h \
+ tests_w32res.rc \
test_files.sh \
test_compress.sh \
test_compress_generated_abc \
LDADD += $(LTLIBINTL)
+# Windows resource compiler support
+.rc.o:
+ $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(RCFLAGS) -i $< -o $@
+
+if COND_W32
+LDADD += tests_w32res.o
+endif
+
check_PROGRAMS = \
create_compress_files \
test_check \
include(CTest)
if(BUILD_TESTING)
+ ################################
+ # Windows Application Manifest #
+ ################################
+
+ # On Windows (but not on Cygwin or MSYS2) we want to add the
+ # application manifest to the test programs so that they are
+ # run in the same configuration as the programs that are installed.
+ # The same object file can be used for all test programs.
+ add_library(tests_w32res OBJECT)
+
+ # CMake requires that even an object library must have at least once
+ # source file. Give it a header file that results in no output files.
+ target_sources(tests_w32res PRIVATE tests/tests.h)
+
+ # The Ninja Generator requires setting the linker language since it
+ # cannot guess the programming language of a header file.
+ set_target_properties(tests_w32res PROPERTIES LINKER_LANGUAGE C)
+
+ target_include_directories(tests_w32res PRIVATE src/common
+ src/common
+ src/liblzma/api
+ )
+
+ if(WIN32)
+ target_sources(tests_w32res PRIVATE tests/tests_w32res.rc)
+ set_source_files_properties(tests/tests_w32res.rc PROPERTIES
+ OBJECT_DEPENDS "${W32RES_DEPENDENCIES}"
+ )
+ endif()
+
#################
# liblzma tests #
#################
src/liblzma
)
- target_link_libraries("${TEST}" PRIVATE liblzma)
+ target_link_libraries("${TEST}" PRIVATE liblzma tests_w32res)
# Put the test programs into their own subdirectory so they don't
# pollute the top-level dir which might contain xz and xzdec.
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_compress")
add_executable(create_compress_files tests/create_compress_files.c)
+ target_link_libraries(create_compress_files PRIVATE tests_w32res)
target_include_directories(create_compress_files PRIVATE src/common)
set_target_properties(create_compress_files PROPERTIES
RUNTIME_OUTPUT_DIRECTORY test_compress)
--- /dev/null
+/* SPDX-License-Identifier: 0BSD */
+
+/*
+ * Author: Lasse Collin
+ */
+
+/*
+ * It's silly to add version info to test programs but GNU windres fails
+ * if there are no resources to build, which happens with Autotools on
+ * Cygwin and MSYS2 because otherwise one more Automake conditional would
+ * be needed.
+ */
+
+#define MY_TYPE VFT_APP
+#define MY_NAME "test"
+#define MY_SUFFIX ".exe"
+#define MY_DESC "Test program"
+#include "common_w32res.rc"