[CMake] CFLAGS and visual studio project properties

Xavier Delannoy xavier.delannoy at netasq.com
Wed Apr 26 11:22:27 EDT 2006


Hi all, 

I use cmake 2.3 (KDE release).
I'm not able to force /MD in release build and /MDd in debug build. here is how I proceed: 

in my CMakeLists.txt

IF(WIN32)
	SET(PLATFORM_C_FLAGS "/W3 /MD /O2 /Gs")
	SET(PLATFORM_C_FLAGS_DEBUG "/W3 /MDd /Zi /Od")
ENDIF(WIN32)

SET(CMAKE_C_FLAGS "${PLATFORM_C_FLAGS}")
SET(CMAKE_C_FLAGS_RELEASE "${PLATFORM_C_FLAGS}")
SET(CMAKE_C_FLAGS_DEBUG "${PLATFORM_C_FLAGS_DEBUG}")


my CMakeCache.txt looks good.

//Flags used by the compiler during debug builds.
CMAKE_C_FLAGS_DEBUG:STRING=/D_DEBUG /MDd /Zi /Ob0 /Od /GZ

//Flags used by the compiler during release minsize builds.
CMAKE_C_FLAGS_MINSIZEREL:STRING=/MD /O1 /Ob1 /D NDEBUG

//Flags used by the compiler during release builds (/MD /Ob1 /Oi
// /Ot /Oy /Gs will produce slightly less optimized but smaller
// files).
CMAKE_C_FLAGS_RELEASE:STRING=/MD /O2 /Ob2 /D NDEBUG

//Flags used by the compiler during Release with Debug Info builds.
//
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=/MD /Zi /O2 /Ob1 /D NDEBUG


whereas .vcproj file doesn't use my CFLAGS ;( ;(
                <Configuration
                        Name="Release|Win32"
                        OutputDirectory="Release"
                        IntermediateDirectory="nbase_shared.dir\Release"
                        ConfigurationType="2"
                        UseOfMFC="0"
                        ATLMinimizesCRunTimeLibraryUsage="FALSE"
                        CharacterSet="2">
                        <Tool
                                Name="VCCLCompilerTool"
                                AdditionalOptions="   /Gs    /Gs -DCMAKE_INTDIR=\&quot;Release\&quot;"
                                AdditionalIncludeDirectories="C:\Projects\Korcula\crossplatform\lib\libnbase\..\
;C:\Projects\Korcula\crossplatform\lib\libnbase\..\libnbase;C:\Projects\Korcula\crossplatform\lib\libnbase\..\li
bnbase\Win32;"
                                ExceptionHandling="FALSE"
                                Optimization="2"
                                RuntimeLibrary="0"
                                WarningLevel="3"
                                PreprocessorDefinitions=",nbase_shared_EXPORTS,&quot;WIN32&quot;,&quot;NETASQ_WI
N32&quot;,&quot;DLL_EXPORT&quot;,"
                                AssemblerListingLocation="Release"
                                ObjectFile="$(IntDir)\"
/>
                        <Tool
                                Name="VCCustomBuildTool"/>
                        <Tool
                                Name="VCResourceCompilerTool"
                                AdditionalIncludeDirectories="C:\Projects\Korcula\crossplatform\lib\libnbase\..\
;C:\Projects\Korcula\crossplatform\lib\libnbase\..\libnbase;C:\Projects\Korcula\crossplatform\lib\libnbase\..\li
bnbase\Win32;"
                                PreprocessorDefinitions=",&quot;WIN32&quot;,&quot;NETASQ_WIN32&quot;,&quot;DLL_E
XPORT&quot;," />
                        <Tool
                                Name="VCMIDLTool"
                                PreprocessorDefinitions=",&quot;WIN32&quot;,&quot;NETASQ_WIN32&quot;,&quot;DLL_E
XPORT&quot;,"
                                MkTypLibCompatible="FALSE"
                                TargetEnvironment="1"
                                GenerateStublessProxies="TRUE"
                                TypeLibraryName="$(InputName).tlb"
                                OutputDirectory="$(IntDir)"
                                HeaderFileName="$(InputName).h"
                                DLLDataFileName=""
                                InterfaceIdentifierFileName="$(InputName)_i.c"
                                ProxyFileName="$(InputName)_p.c"/>
                        <Tool
                                Name="VCPreBuildEventTool"/>
                        <Tool
                                Name="VCPreLinkEventTool"/>
                        <Tool
                                Name="VCPostBuildEventTool"/>
                        <Tool
                                Name="VCLinkerTool"
                                AdditionalOptions="/MACHINE:I386 /STACK:10000000 /machine:I386  "
                                AdditionalDependencies="$(NOINHERIT) kernel32.lib user32.lib gdi32.lib winspool.
lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib "
                                OutputFile="C:\Projects\Korcula\crossplatform\tmp\Release\nbase.dll"
                                LinkIncremental="2"
                                AdditionalLibraryDirectories=""
                                ProgramDatabaseFile="C:\Projects\Korcula\crossplatform\tmp\$(OutDir)\nbase_share
d.pdb"
                                ImportLibrary="C:\Projects\Korcula\crossplatform\tmp\Release\nbase.lib"/>
                </Configuration>

where is my mistake ? 

regards,

-- 
Xavier Delannoy


More information about the CMake mailing list