title: CMake override native compiler flags
body: <p>I am trying to build a c project with CMake using Visual Studio 14 however I cannot override the compiler flags being set by CMake which are causing project to fail to build.  I am using this method in my CMakeLists.txt file</p>
  
  <pre><code>set(flags /nologo /c /EHsc /GS- /MTd /Od /TC /Zi /Zp2 /D _USING_V110_SDK71_)
  set(CMAKE_C_FLAGS ${flags})
  set(rc_flags /l0x809)
  set(CMAKE_RC_FLAGS ${rc_flags})
  set(linker_flags /NOLOGO /SUBSYSTEM:console /MACHINE:I386 /DLL)
  set(CMAKE_LINKER_FLAGS ${linker_flags})
  </code></pre>
  
  <p>Any help would greatly be appreciated!</p>
  
  <p>Edit: full example of main CMakeLists.txt is here</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.4)
  project(cuism C)
  
  set(WINDOWS_SDK_INCLUDES "C:/Program Files\ (x86)/Microsoft\  SDKs/Windows/v7.1A/Include/")
  set(WINDOWS_SDK_LIBRARIES "C:/Program Files\ (x86)/Microsoft\ SDKs/Windows/v7.1A/Lib")
  set(WSOCK "WSock32.lib")
  set(ODBC "odbc32.lib")
  set(ODBCCP "odbccp32.lib")
  
  set(includeDir "${CMAKE_SOURCE_DIR}/include/")
  set(resourceDir "${CMAKE_SOURCE_DIR}/resources/")
  
  
  include_directories(
      ${includeDir}
      ${resourceDir}
  )
  
  set(CMAKE_LIBRARY_PATH ${WINDOWS_SDK_LIBRARIES})
  set(CMAKE_INCLUDE_PATH ${WINDOWS_SDK_INCLUDES})
  
  
  set(flags "/nologo /c /EHsc /GS- /MTd /Od /TC /Zi /Zp2 /D _USING_V110_SDK71_" )
  set(CMAKE_C_FLAGS ${flags})
  
  set(rc_flags /l0x809)
  set(CMAKE_RC_FLAGS ${rc_flags})
  
  set(linker_flags /NOLOGO /SUBSYSTEM:console /DLL)
  set(CMAKE_LINKER_FLAGS ${linker_flags})
  
  message(c flags are ${CMAKE_C_FLAGS})
  message(rc flags are ${CMAKE_RC_FLAGS})
  message(linker flags are ${CMAKE_LINKER_FLAGS})
  message(linker EXE flags are ${CMAKE_EXE_LINKER_FLAGS})
  
  set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
  set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
  set(RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
  
  
  ADD_SUBDIRECTORY(cuimbct)
  ADD_SUBDIRECTORY(cuimb)
  ADD_SUBDIRECTORY(cuidll)
  </code></pre>
  
  <p>Each sudbdirectory has a CMakeLists.txt similar to this one</p>
  
  <pre><code>set(src cuimb.c "${includeDir}port.c" cuimben.c cuimb.rc)
  add_library(cuimb SHARED ${src})
  target_link_libraries(cuimb ${WSOCK} ${ODBC} ${ODBCCP})
  </code></pre>
  
  <p>Error is during linking stage due to error code LNK2019</p>