From 276e7e21a3bfa862ca5f966fbba5ed6390fcf1ae Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Aug 2006 15:33:20 -0400 Subject: ENH: Adding flags to force generation of manifest files when building with VC 8. --- Modules/CMakeVCManifest.cmake | 30 ++++++++++++++++++++++++++++++ Modules/Platform/Windows-cl.cmake | 19 +++++++++++++------ Source/cmLocalVisualStudio7Generator.cxx | 2 ++ 3 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 Modules/CMakeVCManifest.cmake diff --git a/Modules/CMakeVCManifest.cmake b/Modules/CMakeVCManifest.cmake new file mode 100644 index 0000000..6675f99 --- /dev/null +++ b/Modules/CMakeVCManifest.cmake @@ -0,0 +1,30 @@ + +# Leave the first line of this file empty so this module will not be +# included in the documentation. + +# This script is invoked from Windows-cl.cmake and passed the TARGET +# variable on the command line. + +# Conditionally embed the manifest in the executable if it exists. +IF(EXISTS "${TARGET}.manifest") + # Construct the manifest embedding command. + SET(CMD + mt ${CMAKE_CL_NOLOGO} /manifest ${TARGET}.manifest + /outputresource:${TARGET} + ) + + # Run the embedding command. + EXECUTE_PROCESS(COMMAND ${CMD}\;\#2 RESULT_VARIABLE RESULT) + + # Check whether the command failed. + IF(NOT "${RESULT}" MATCHES "^0$") + # The embedding failed remove the target and the manifest. + FILE(REMOVE ${TARGET} ${TARGET}.manifest) + + # Describe the failure in a message. + STRING(REGEX REPLACE ";" " " CMD "${CMD}") + MESSAGE(FATAL_ERROR + "Failed to embed manifest in ${TARGET} using command \"${CMD};#2\"" + ) + ENDIF(NOT "${RESULT}" MATCHES "^0$") +ENDIF(EXISTS "${TARGET}.manifest") diff --git a/Modules/Platform/Windows-cl.cmake b/Modules/Platform/Windows-cl.cmake index 9a99652..d5c1976 100644 --- a/Modules/Platform/Windows-cl.cmake +++ b/Modules/Platform/Windows-cl.cmake @@ -209,17 +209,21 @@ ENDIF(CMAKE_FORCE_WIN64) # default to Debug builds IF(MSVC80) # for 2005 make sure the manifest is put in the dll with mt - SET(CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}" - "mt ${CMAKE_CL_NOLOGO} /manifest .manifest /outputresource:\;#2") + SET(CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}" + "$(CMAKE_COMMAND) -DTARGET= -DCMAKE_CL_NOLOGO=${CMAKE_CL_NOLOGO} -P \"${CMAKE_ROOT}/Modules/CMakeVCManifest.cmake\"" + ) SET(CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}") # create a C shared library SET(CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}") # create a C shared module just copy the shared library rule SET(CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_C_CREATE_SHARED_LIBRARY}") SET(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}" - "mt ${CMAKE_CL_NOLOGO} /manifest .manifest /outputresource:\;#2") + "$(CMAKE_COMMAND) -DTARGET= -DCMAKE_CL_NOLOGO=${CMAKE_CL_NOLOGO} -P \"${CMAKE_ROOT}/Modules/CMakeVCManifest.cmake\"" + ) SET(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}" - "mt ${CMAKE_CL_NOLOGO} /manifest .manifest /outputresource:\;#2") + "$(CMAKE_COMMAND) -DTARGET= -DCMAKE_CL_NOLOGO=${CMAKE_CL_NOLOGO} -P \"${CMAKE_ROOT}/Modules/CMakeVCManifest.cmake\"" + ) + SET(CMAKE_BUILD_TYPE_INIT Debug) SET (CMAKE_CXX_FLAGS_INIT "/DWIN32 /D_WINDOWS /W3 /Zm1000 /EHsc /GR") SET (CMAKE_CXX_FLAGS_DEBUG_INIT "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1") @@ -232,6 +236,7 @@ IF(MSVC80) SET (CMAKE_C_FLAGS_RELEASE_INIT "/MD /O2 /Ob2 /D NDEBUG") SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "/MD /Zi /O2 /Ob1 /D NDEBUG") SET (CMAKE_C_STANDARD_LIBRARIES_INIT "kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib ") + SET (CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} /MANIFEST") ELSE(MSVC80) IF(CMAKE_USING_VC_FREE_TOOLS) MESSAGE(STATUS "Using FREE VC TOOLS, NO DEBUG available") @@ -269,9 +274,11 @@ SET(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}") SET (CMAKE_LINK_DEF_FILE_FLAG "/DEF:") # set the stack size and the machine type IF(CMAKE_CL_64) - SET (CMAKE_EXE_LINKER_FLAGS_INIT "/STACK:10000000 /machine:x64") + SET (CMAKE_EXE_LINKER_FLAGS_INIT + "${CMAKE_EXE_LINKER_FLAGS_INIT} /STACK:10000000 /machine:x64") ELSE(CMAKE_CL_64) - SET (CMAKE_EXE_LINKER_FLAGS_INIT "/STACK:10000000 /machine:I386") + SET (CMAKE_EXE_LINKER_FLAGS_INIT + "${CMAKE_EXE_LINKER_FLAGS_INIT} /STACK:10000000 /machine:I386") ENDIF(CMAKE_CL_64) # add /debug and /INCREMENTAL:YES to DEBUG and RELWITHDEBINFO also add pdbtyp diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 784ce0c..e8a5dba 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -326,6 +326,8 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] = { // option flags (some flags map to the same option) + {"GenerateManifest", "MANIFEST:NO", "disable manifest generation", "FALSE"}, + {"GenerateManifest", "MANIFEST", "enable manifest generation", "TRUE"}, {"LinkIncremental", "INCREMENTAL:NO", "link incremental", "1"}, {"LinkIncremental", "INCREMENTAL:YES", "link incremental", "2"}, {0,0,0,0 } -- cgit v0.12