Permalink
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (24 sloc) 1.75 KB

Libefp and CMake

Building

cmake -H. -Bobjdir
cd objdir && make
make install

The build is also responsive to

  • static/shared toggle BUILD_SHARED_LIBS
  • install location CMAKE_INSTALL_PREFIX
  • name/name_L in library fragments toggle FRAGLIB_UNDERSCORE_L
  • shallow/deep library fragments directory structure toggle FRAGLIB_DEEP
  • CMAKE_C_COMPILER and CMAKE_C_FLAGS

See CMakeLists.txt for options details and additional options. All these build options should be passed as cmake -DOPTION.

Detecting

This project installs with libefpConfig.cmake, libefpConfigVersion.cmake, and libefpTargets.cmake files suitable for use with CMake find_package() in CONFIG mode.

  • find_package(libefp) - find any libefp libraries and headers
  • find_package(libefp 1.5.0 EXACT CONFIG REQUIRED COMPONENTS static) - find libefp of exactly specified version built with static libraries; abort on failure

See libefpConfig.cmake.in for details of how to detect the Config file and what CMake variables and targets are exported to your project.

Using in CMake-based projects

After find_package(libefp ...),

  • test if package found with if(${libefp_FOUND}) or if(TARGET libefp::efp)
  • link to library (establishes dependency), including header and definitions configuration with target_link_libraries(mytarget libefp::efp)
  • include header files using target_include_directories(mytarget PRIVATE $<TARGET_PROPERTY:libefp::efp,INTERFACE_INCLUDE_DIRECTORIES>)
  • compile target applying -DUSING_libefp definition using target_compile_definitions(mytarget PRIVATE $<TARGET_PROPERTY:libefp::efp,INTERFACE_COMPILE_DEFINITIONS>)