On 06/17/2015 05:52 AM, Eric Wing wrote:
> To meet these objectives, I see two things we need to do:
> - For the first and simplest case, we need to enhance the CMake Xcode
> generator so it can handle Swift. Xcode already knows how to handle
> Swift files automatically, so we should leverage it by making CMake
> generate a correct project for it.
Let's start with Xcode and make enabling the language an error for
other generators at first.
> GetSourcecodeValueFromFileExtension(), I added swift right after the
> Obj-C entries.
>
> else if (ext == "swift")
> {
> sourcecode += ".swift";
> }
Good.
> set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m;swift)
>
> This works pretty well for my initial test case which is a mixture of
> C/Obj-C/Swift. But I was told we should be looking at building a
> separate language generator instead of this latter hack.
Right. There have been efforts here in the past to make separate
OBJC and OBJCXX languages too. Using the C and CXX languages for
those has always been a partial solution. For Swift we should do it
right the first time.
> CMakeDetermineSwiftCompiler.cmake
Let's start by getting that to work for the Xcode generator. Currently
Modules/CompilerId/Xcode-3.pbxproj.in gets configured by the
CMAKE_DETERMINE_COMPILER_ID_BUILD function as a small test project
to compile the C or C++ source for compiler identification. From
the output of that build we are able to extract the path to the
compiler tool. One would have to do something similar here. Can
you provide a minimal pbxproj file and swift source file that
work together to build an executable?
> - However, since Swift is designed to operate with C and Obj-C, there
> does seem to be a mechanism to create files that can be linked with
> C/Obj-C (needed by the Makefile generator; should be automatic by
> Xcode)
What is the proper sequence of commands to build some C and Swift
sources and link a single executable? library?
Thanks,
-Brad
--
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-developers