[CMake] setting clrsupport VS2010

Benjamin Ballet bballet at ivsweb.com
Wed Oct 19 09:04:25 EDT 2016


Hi
here is all the property I had to set to produce C++/CLI (clr) targets with
cmake


    target_compile_options(${project_name} PRIVATE /clr)
    target_compile_options(${project_name} PRIVATE /fp:precise) #
/fp:strict is incompatible with /clr

    set_property(TARGET ${project_name} PROPERTY VS_GLOBAL_ROOTNAMESPACE
${project_name})

    set_property(TARGET ${project_name} PROPERTY VS_GLOBAL_KEYWORD
"ManagedCProj")

    set_property(TARGET ${project_name} PROPERTY VS_GLOBAL_CLRSupport
"true")

    set_property(TARGET ${project_name} PROPERTY
VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.0")

    set_property(TARGET ${project_name} PROPERTY VS_DOTNET_REFERENCES
"System" "System.Data" "System.Drawing" "System.Windows.Forms" "System.Xml")

    # Note: Modification of compiler flags is required for CLR
compatibility now that we are using .resx files.
    string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
    string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG}")

2016-10-19 12:08 GMT+02:00 Swetha Sharma <swetha.bsharma at gmail.com>:

> I am trying to create a managed c++ code , i want to thes clrsupport to be
> true from cmake. Below is the script which  i have used
>
> SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/clr")
>  STRING(REPLACE "/EHsc" "/EHa" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
>  STRING(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
>  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /clr")
>
> The problem I've found, is that while CMake sets the "Common Language
> RunTime Support" option in the C/C++ section of the configuration
> properties
> if "/clr" is in the CXX_FLAGS, it does not set the "Common Language RunTime
> Support" in the general configuration properties, and that causes problems
> with linking/.NET references.
>
>
> How do I fix this issue?
> -swetha
>
> --
>
> 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
>



-- 
*Benjamin BALLET*
Ingénieur R&D

*ACTIVISU*
19, rue Klock - 92110 Clichy
*> Standard Tél* :  01 44 69 37 37
*>* www.activisu.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161019/42308e12/attachment-0001.html>


More information about the CMake mailing list