mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
A target created by `add_custom_target` should always be a `.vcxproj` file even if it has `.cs` sources involved in custom commands and such. The latter case was broken by refactoring in commit v3.12.0-rc1~160^2~7 (remove TargetIsCSharpOnly() and use methods from cmGeneratorTarget, 2018-03-19). The reason is that the `HasLanguage` method added by commit v3.12.0-rc1~239^2~6 (cmGeneratorTarget: add HasLanguage() as wrapper for GetLanguages(), 2018-03-19) does not check the target type and so is not a suitable check for deciding the project file extension. The `HasLanguage` method was an attempt at an abstraction that turns out not to work very well. Replace it with a dedicated `IsCSharpOnly` method that considers the target type, sources, and non-transitive `LINKER_LANGUAGE`. Fixes: #18515
14 lines
385 B
CMake
14 lines
385 B
CMake
# 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)
|
|
|
|
add_custom_target(CSharpCustom ALL SOURCES empty.cs)
|
|
add_custom_target(custom.cs ALL DEPENDS empty.txt)
|