Coder Social home page Coder Social logo

cmake-modules's Introduction

DEPRECIATED

Use FindBerkeleyDB or install_and_export instead. I separated the modules for easy git submodule support.


These are just some Cmake modules I made, which I figured someone could benefit from.

Overview of modules

Module Info Usage
FindBerkeleyDB Finds Berkeley DB, and outputs the paths of the include & libs folders. Note: Only tested on v5 & v6 of Berkeley DB. find_package(BerkeleyDB "5.23.0") which outputs BERKELEYDB_INCLUDE_DIRS & BERKELEYDB_LIBRARIES
install_and_export Defines a simple macro for easy installation & exporting of executables/libraries. install_and_export(exe_name_here)

Usage

To use a module, copy it into a cmake/modules folder in your project, then use list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") in your main CmakeLists.txt.

Afterwards, you can include(module_name_here), or find_package(PackageName) for a FindPackage module, to use their functionality.

Example CmakeLists.txt

# ~~ Example usage in CmakeLists.txt ~~
CMAKE_MINIMUM_REQUIRED(VERSION 3.0 FATAL_ERROR)
project(Example VERSION "1.2.3" LANGUAGES CXX)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")

add_executable(my_exe main.cpp)

# ~~ Example of FindBerkeleyDB usage ~~
find_package(BerkeleyDB "5.23.0" REQUIRED)
target_link_libraries(my_exe PRIVATE ${BERKELEYDB_LIBRARIES})
target_include_directories(my_exe
  PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  PRIVATE ${BERKELEYDB_INCLUDE_DIRS}
)

# ~~ Example of install_and_export usage ~~
include(install_and_export)
# It's necessary when using install_and_export() to use generator expressions on includes
target_include_directories(my_exe
  PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
install_and_export(my_exe)

cmake-modules's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.