chicagohoogl.blogg.se

Cmake linux shared library
Cmake linux shared library








If you set cmake_minimum_required(VERSION 3.9) or better (see CMP0069), setting this to ON on a target is an error if the compiler doesn't support it. Support for GCC and Clang was added in CMake 3.8. You can turn this on with CMAKE_INTERPROCEDURAL_OPTIMIZATION (CMake 3.9+ only) or the INTERPROCEDURAL_OPTIMIZATION property on targets. INTERPROCEDURAL*OPTIMIZATION, best known as _link time optimization* and the -flto flag, is available on very recent versions of CMake. See the chapter on existing package inclusion for more. You can pretty easily find Find*.cmake's for this and other libraries that you need with a quick search most major packages have a helper library of CMake modules. If you need to link to the dl library, with -ldl on Linux, just use the built-in CMake variable $) To explicitly turn it ON (or OFF) for a target. Will do it globally, or: set_target_properties(lib1 PROPERTIES POSITION_INDEPENDENT_CODE ON) If you do explicitly need it: set(CMAKE_POSITION_INDEPENDENT_CODE ON) CMake will include the flag for SHARED or MODULE libraries.

cmake linux shared library

Much of the time, you don't need to do anything. The first and most common feature was C++ standards support, which got it's own chapter. And, better yet, you explain what you mean in your CMakeLists, rather than spewing flags.

cmake linux shared library

When you need to add something special, you could check first to see if CMake supports it if it does, you can avoid explicitly tying yourself to a compiler version. There are lots of compiler and linker settings.










Cmake linux shared library