Hello

Firstly I am very new to CMake, C and Visual Studio so please excuse my 
ignorance!

My problem is I am trying to convert an old Visual Studio 6 project into a 
Visual Studio 14 2015 solution using CMake, however I am having difficulties 
settings compiler flags.  I have been unable to find relevant documentation or 
advice on web on how to achieve the necessary builds steps I need to achieve.  
The build I am trying to achieve is as following;


1.       Use cl.exe to compile source but not link code

2.       Use rc.exe to embed resource file into object code

3.       Use link.exe to link objects into a DLL

The problem I am having is the link stage probably due to an issue with the 
compiler flags I am setting via CMAKE_C_FLAGS, CMAKE_RC_FLAGS and 
CMAKE_LINKER_FLAGS, they appear not to override the default CMAKE settings.

I have attached a copy of my CMakeLists.txt file to see if I am missing the 
obvious!

Thanks in advance
Simon


cmake_minimum_required(VERSION 3.4)

project(example C)

set(SDK_INCLUDE_PATH "C:/Program Files\ (x86)/Microsoft\ 
SDKs/Windows/v7.1A/Include/")
set(WIN32_LIB_PATH "C:/Program Files\ (x86)/Microsoft\ SDKs/Windows/v7.1A/Lib")
set(WIN_32_LIB "WSock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib 
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib 
odbc32.lib odbccp32.lib")

set(includeDir "${CMAKE_SOURCE_DIR}/include/")
set(resourceDir "${CMAKE_SOURCE_DIR}/resources/")

include_directories(
    ${includeDir}
    ${SDK_INCLUDE_PATH}
    ${resourceDir}
)

link_directories(
    "${WIN32_LIB_PATH} ${WIN_32_LIB}"
)


set(src example.c "${includeDir}example1.c" example.rc)

set(c_flags "/nologo /c /EHsc /GS- /MTd /Od /TC /Zi /Zp2 /D _USING_V110_SDK71_" 
)
set(CMAKE_C_FLAGS "${c_flags}")

set(rc_flags "/l 0x809")
set(CMAKE_RC_FLAGS "${rc_flags}")

set(linker_flags /NOLOGO /SUBSYSTEM:console /MACHINE:I386 /DLL)
set(CMAKE_LINKER_FLAGS "${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_library(cuimbct SHARED ${src})
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to