[CMake] mixed-source executables

Luke Dalessandro luked at cs.rochester.edu
Thu Jun 23 08:50:04 EDT 2011


Hi everyone,

I have two questions about building mixed-source executables. First, the context:

I am using an experimental C++ compiler that adds support for some additional language features. The compiler produces standard object files for my platform. I've added a custom language to cmake, CXXEX, that can compile source files that use the additional language features (.cxxex files).

I don't do any linking with the experimental compiler, nor do I compile standard C++ files with it, generally because it appears to generate debugging information that is only marginally compatible with the gdb on my system---minimizing the exposure of cxxex files helps here. I use the configured CXX compiler for C++ files and for linking. This is generally g++.

During configuration CMake automatically detects the CMAKE_CXXEX_IMPLICIT_LINK_(DIRECTORIES/LIBRARIES) used by the experimental compiler. When linking the mixed-source executable, it automatically adds these to the link command, which _is_ the behavior that I need, however there are two problems.

1) 

The implicit link directories are either the 32-bit directories, or the 64-bit directories, depending on the presence of -m32/-64 in the CXXEX_FLAGS when enable_language is called. I'm no cmake expert, but I think the result of this is that I either can't provide a CMakeCXXEXCompiler.cmake.in cache for the language, and need to redetect the language every time configuration happens, or can't provide an option to the user that allows them to change the build from 32 to 64 bit mode after the initial configuration.

Is there any existing cmake mechanism that can solve this problem, i.e., let me provide a configuration variable that can be changed after the initial configuration? I could use an internal cache variable to detect the change, but I'm not sure how to force a reconfiguration of CXXEX if a configured CMakeCXXEXCompiler.cmake exists, would I just delete it?

2)

The implicit link directories are added to the link command line with a -L flag, but I would actually prefer that they get added with a -R to get them embedded as an rpath. Is this something that is easily changed in the definition of the CXXEX language? There are a bunch of variables in CMakeCXXInformation.cmake (which I've copied for CXXEX) that I don't understand, is one of them what I need, or is it embedded in the definition of how to link a CXX executable somewhere?

Thanks,
Luk


More information about the CMake mailing list