For every library that is defined which has the EXCLUDE_FROM_ALL property set the EXCLUDE_FROM_DEFAULT_BUILD property is set as well.The original function is still available as e.g. First, a trick I like to use: Functions like add_library and target_link_libraries can be “overridden” by just defining a new version.function ( add_library TARGET ) _add_library ( $ ) endif () endfunction () # Override add_library() and set the "EXCLUDE_FROM_DEFAULT_BUILD" property to TRUE on all libraries that use "EXCLUDE_FROM_ALL". Others seem to have wanted to do the same: A (CMake-) project consists of one or more executables.A bunch of static libraries in the shared codebase where not every library is needed in every project.While this works, I don’t like it: People are used to hitting F7 (or whatever the shortcut is) and the project should build. This doesn’t mean that EXCLUDE_FROM_ALL is ineffective with Visual Studio: If you build the “ALL_BUILD” project, you’ll get the same behaviour as with Make. The difference to EXCLUDE_FROM_ALL: If a target is excluded from build like that, it won’t be built even if another target depends on it. a Visual Studio project) isn’t built when the Solution is build by pressing “Build Solution (F7)”. Interestingly, there’s the EXCLUDE_FROM_DEFAULT_BUILD target property which on first sight seems to be somewhat redundant.īut it isn’t, it’s a property specific to the Visual Studio generator and only says that a target (i.e. I’m not sure if this use case is what the implementor of EXCLUDE_FROM_ALL had in mind, but I find it practical like that. This reduces build times and makes it easier to handle component-dependencies. in your shared codebase) and only those that are actually needed will be built. Like this, you can define a bunch of libraries (e.g. )), the library will be built nevertheless if another target (library or executable) depends on it. by using add_library(target EXCLUDE_FROM_ALL. This currently doesn’t work (well) for Visual Studio generators, but here’s a trick how to get this behaviour in Visual Studio as well…Īs written in the CMake docs, the EXCLUDE_FROM_ALL target-property causes a target to be excluded from the “all” build-target, which is the default if make is started without any args. ) is really convenient with Make-generators if you want to define libraries that should only be built if another target depends on them. When gcc / mingw is in the path then everything works fine.Add_library(target EXCLUDE_FROM_ALL. Configuring incomplete, errors occurred! You probably need to select a different build tool.ĬMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.ĬMake Error: Could not find cmake module file:D:/Development/build/CMakeFiles/CMakeCCompiler.cmakeĬMake Error: Could not find cmake module file:D:/Development/build/CMakeFiles/CMakeCXXCompiler.cmakeĬMake Error: CMAKE_C_COMPILER not set, after EnableLanguageĬMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage \sourceĬMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". If the PATH is not set up correctly it will fail with something like:ĭ:\Development\build>cmake -G "Unix Makefiles". This is not what I get, when I run the same command, cmake will look for a gcc compiler / make utility. This is surely not the most elegant solution, though -) Maybe use a batch file that will actually execute the cmake -G generator for the user. source afterwards, it will use the generator as specified in the CMAKE_GENERATOR variable in the cache. The variable CMAKE_GENERATOR is stored in the cache, though. source (without -G) the default generator is used. In CMakeLists.txt, then in the very first run of cmake. If you use something like set(CMAKE_GENERATOR "Ninja" CACHE INTERNAL "" FORCE) So the variable is only set at the very end of the generation procedure. Build files have been written to: /tmp/build The C compiler identification is GNU 4.9.2 You can see in the output something like % cmake. If you use (even at the beginning of CMakeLists.txt) set(CMAKE_GENERATOR "Ninja") It seems to me that the variable CMAKE_GENERATOR is set too late if set in the CMakeLists.txt.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |