Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • CMake CMake
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 4,107
    • Issues 4,107
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 19
    • Merge requests 19
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • CMakeCMake
  • CMakeCMake
  • Issues
  • #18184
Closed
Open
Issue created Jul 18, 2018 by Ram-Z@Ram-ZContributor

UseSWIG: swig_add_library fails on csharp output

When trying to use swig_add_library, configure step fails with CMake Error.

CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_CSharp_COMPILE_OBJECT

Minimal reproduction:

cmake_minimum_required(VERSION 3.12)

find_package(SWIG)
include(UseSWIG)

file(WRITE test.i "%module test")

swig_add_library(csharp
	TYPE MODULE
	LANGUAGE csharp
	SOURCES test.i)

Applying the following patch will fix the issue.

diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index 8424a9ffc..02cd2bd4f 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -309,7 +309,7 @@ function(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile)
   foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSIONS})
     set(extra_file "${generatedpath}/${module_basename}${it}")
     if (extra_file MATCHES "\\.cs$")
-      set_source_files_properties(${extra_file} PROPERTIES LANGUAGE "CSharp")
+      set_source_files_properties(${extra_file} PROPERTIES LANGUAGE "")
     else()
       # Treat extra outputs as plain files regardless of language.
       set_source_files_properties(${extra_file} PROPERTIES LANGUAGE "")

I believe the issue will only appear on platforms that do not support building CSharp, i.e. everything but Windows.

Ref: !2137 (merged) and !2137 (0c2fb4c8, comment 420395)

Edited Jul 18, 2018 by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking