Commit 47d391d7 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'csharp_simple'

397b8546 VS: added documentation for C# support
a7dd8e66 VS: added support for C# (for Visual Studio 2010, 2012, 2013, 2015)
6fda6005 VS: renamed target property VS_USER_PROPS_CXX to VS_USER_PROPS
parents a67baf0a 397b8546
......@@ -291,7 +291,7 @@ Properties on Targets
/prop_tgt/VS_SCC_PROJECTNAME
/prop_tgt/VS_SCC_PROVIDER
/prop_tgt/VS_SDK_REFERENCES
/prop_tgt/VS_USER_PROPS_CXX
/prop_tgt/VS_USER_PROPS
/prop_tgt/VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION
/prop_tgt/VS_WINRT_COMPONENT
/prop_tgt/VS_WINRT_EXTENSIONS
......
VS_USER_PROPS_CXX
-----------------
VS_USER_PROPS
-------------
Sets the user props file to be included in the visual studio
C++ project file. The standard path is
......
vs-native-csharp-support
------------------------
* The :ref:`Visual Studio Generators` for VS 2010 and above
learned to support the C# language. C# assemblies and
programs can be added just like common C++ targets using
the :command:`add_library` and :command:`add_executable`
commands. Referencing between several C# targets in the same
source tree is done by :command:`target_link_libraries` like
for C++. Referencing to system or 3rd party assemblies is
done by the target properties :prop_tgt:`VS_DOTNET_REFERENCE_<refname>`
and :prop_tgt:`VS_DOTNET_REFERENCES`.
* C# as a language can be enabled using :command:`enable_language`
or :command:`project` with ``CSharp``. It is not enabled by
default.
* Flag variables, target properties and other configuration
that specifically targets C# contains ``CSharp`` as a part of
their names.
* More finetuning of C# targets can be done using target
properties. Specifically the Visual Studio related target
properties (``VS_*``) are worth a look (for setting toolset
versions, root namespaces, assembly icons, ...).
......@@ -3,7 +3,7 @@ vs-custom-msbuild-props
* The :ref:`Visual Studio Generators` for VS 2010 and above can
now be fine tuned using custom msbuild .props files.
:prop_tgt:`VS_USER_PROPS_CXX` can be
:prop_tgt:`VS_USER_PROPS` can be
used to change the default path of the user .props file from
``$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props`` to
an arbitrary filename.
......@@ -34,10 +34,6 @@ if(NOT CMAKE_CSharp_COMPILER_WORKS)
# Move result from cache to normal variable.
set(CMAKE_CSharp_COMPILER_WORKS ${CMAKE_CSharp_COMPILER_WORKS})
unset(CMAKE_CSharp_COMPILER_WORKS CACHE)
if(NOT CMAKE_CSharp_COMPILER_WORKS)
message("forcing compiler works to true (will be removed once C# support is integrated)")
set(CMAKE_CSharp_COMPILER_WORKS 1)
endif()
set(CSharp_TEST_WAS_RUN 1)
endif()
......
This diff is collapsed.
......@@ -56,6 +56,7 @@ private:
void WriteProjectConfigurations();
void WriteProjectConfigurationValues();
void WriteMSToolConfigurationValues(std::string const& config);
void WriteMSToolConfigurationValuesManaged(std::string const& config);
void WriteHeaderSource(cmSourceFile const* sf);
void WriteExtraSource(cmSourceFile const* sf);
void WriteNsightTegraConfigurationValues(std::string const& config);
......
......@@ -325,6 +325,9 @@ if(BUILD_TESTING)
endif()
endif()
if(${CMAKE_GENERATOR} MATCHES "Visual Studio ([^789]|[789][0-9])")
ADD_TEST_MACRO(CSharpOnly CSharpOnly)
endif()
ADD_TEST_MACRO(COnly COnly)
ADD_TEST_MACRO(CxxOnly CxxOnly)
......
# a simple CSharp only test case
project (CSharpOnly CSharp)
# C# does not make any difference between STATIC and SHARED libs
add_library(lib1 STATIC lib1.cs)
add_library(lib2 SHARED lib2.cs)
add_executable(CSharpOnly csharponly.cs)
target_link_libraries(CSharpOnly lib1 lib2)
namespace CSharpOnly
{
class CSharpOnly
{
public static void Main(string[] args)
{
int val = Lib1.getResult();
Lib2 l = new Lib2();
val = l.myVal;
return;
}
}
}
namespace CSharpOnly
{
public class Lib1
{
public static int getResult()
{
return 23;
}
}
}
namespace CSharpOnly
{
public class Lib2
{
public int myVal = 42;
public Lib2()
{}
}
}
......@@ -4,4 +4,4 @@ add_library(foo foo.cpp)
set(props_file "${CMAKE_CURRENT_SOURCE_DIR}/my.props")
set_target_properties(foo PROPERTIES
VS_USER_PROPS_CXX "${props_file}")
VS_USER_PROPS "${props_file}")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment