我使用CMake为Visual Studio生成了一个解决方案。它会像原始解决方案一样编译罚款。但是当我查看我的输出文件夹时,这些文件的大小与初始解决方案生成的文件大小不同。
示例:
初始解决方案产生的DLL:
core.dll - 767ko
通过CMake的解决方案生成相同的DLL:
core.dll - 669Ko
同样的事情出现在.lib上:
zlib.lib - 305 Ko(初始解决方案)
zlib.lib - 242 Ko(用于CMake解决方案)
但我使用Visual Studio 2013两个......而且类型是相同的:Debug / Win32。我多次验证所有Flags,但无论如何它仍会生成不同大小的文件。
编辑:我添加了我的CMakeLists
cmake_minimum_required(VERSION 2.8)
# Configuration of Types
MESSAGE("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}")
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
#SET(CMAKE_CACHEFILE_DIR ${BUILD_PATH})
#Configuration of zlib.lib
PROJECT(zlib C)
# Path of Release
SET(LIB_RELEASE_PATH "../build/cmake_x64")
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${LIB_RELEASE_PATH}/lib/" )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${LIB_RELEASE_PATH}/lib/" )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${LIB_RELEASE_PATH}/lib/" )
# Path of Debug
SET(LIB_DEBUG_PATH "../build/cmake_x64d")
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${LIB_DEBUG_PATH}/lib/" )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${LIB_DEBUG_PATH}/lib/" )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${LIB_DEBUG_PATH}/lib/" )
#Flags
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /D_UNICODE")
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /GL /Oi /Gy /GR- /Gm-")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Gm /Ob0- /GR- /Gm")
# Files of librairy
ADD_LIBRARY(
zlib
STATIC
../.c
and
../.h
)
#Configuration of core.dll
project(core CXX)
# Path of Release
SET(BIN_RELEASE_PATH "../build/cmake_x64")
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${BIN_RELEASE_PATH}/bin/" )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${BIN_RELEASE_PATH}/bin/" )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${BIN_RELEASE_PATH}/bin/" )
# Path of Debug
SET(BIN_DEBUG_PATH "../build/cmake_x64d")
SET( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${BIN_DEBUG_PATH}/bin/" )
SET( CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${BIN_DEBUG_PATH}/bin/" )
SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${BIN_DEBUG_PATH}/bin/" )
# Flags
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /D_UNICODE /D_USRDLL /DCORE_EXPORTS /DUNICODE")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /GL /Oi /Gy /DEBUG /INCREMENTAL:NO /GR- /Gm-")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Gm /GR-")
# Files of librairy
add_library(
core
SHARED
../.h
and
../.cpp
)
target_link_libraries(core zlib)
SET_PROPERTY(TARGET core APPEND PROPERTY LINK_FLAGS /DEBUG)
#END OF FILE
这是命令行的输出:
Generated with config types:
-- The C compiler identification is MSVC 18.0.21005.1
-- Check for working C compiler using: Visual Studio 12 2013
-- Check for working C compiler using: Visual Studio 12 2013 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- The CXX compiler identification is MSVC 18.0.21005.1
CMake Warning (dev) at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMak
eDetermineCXXCompiler.cmake:106 (if):
Policy CMP0054 is not set: Only interpret if() arguments as variables or
keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.
Quoted variables like "MSVC" will no longer be dereferenced when the policy
is set to NEW. Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
CMakeLists.txt:61 (project)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMak
eFindBinUtils.cmake:33 (if):
Policy CMP0054 is not set: Only interpret if() arguments as variables or
keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.
Quoted variables like "MSVC" will no longer be dereferenced when the policy
is set to NEW. Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/CMakeDetermineCXXCompiler
.cmake:162 (include)
CMakeLists.txt:61 (project)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Check for working CXX compiler using: Visual Studio 12 2013
-- Check for working CXX compiler using: Visual Studio 12 2013 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/mea/Documents/developpement/Repos/
corealpi2/cmake/build
有没有人知道可能导致这种情况的原因?
由于