Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslo committed Mar 28, 2019
0 parents commit 520cef3
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 0 deletions.
53 changes: 53 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
cmake_minimum_required(VERSION 3.2)

option(CMAKE_VERBOSE_MAKEFILE "..." ON)

project(bar)

add_library(bar bar/bar.cpp bar/bar.hpp)
add_library(bar::bar ALIAS bar)

target_include_directories(
bar PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
)

include(GNUInstallDirs)

set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")

include(CMakePackageConfigHelpers)

configure_package_config_file(
"cmake/template/Config.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${config_install_dir}"
)

install(
TARGETS bar
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)

install(
FILES bar/bar.hpp
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}"
)

install(
FILES "${project_config}"
DESTINATION "${config_install_dir}"
)

install(
EXPORT "${TARGETS_EXPORT_NAME}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}"
)
13 changes: 13 additions & 0 deletions bar/bar.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <bar/bar.hpp>

#include <iostream> // std::cout

namespace bar
{

void bar::Run()
{
std::cout << "bar::Run" << std::endl;
}

} // namespace bar
15 changes: 15 additions & 0 deletions bar/bar.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef BAR_BAR_HPP_
#define BAR_BAR_HPP_

namespace bar
{

class bar
{
public:
void Run();
};

} // namespace bar

#endif // BAR_BAR_HPP_
4 changes: 4 additions & 0 deletions cmake/template/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
check_required_components("@PROJECT_NAME@")

0 comments on commit 520cef3

Please sign in to comment.