-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9f5020b
Showing
4 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(foo) | ||
|
||
add_library(foo foo/foo.cpp foo/foo.hpp) | ||
add_library(foo::foo ALIAS foo) | ||
|
||
target_include_directories( | ||
foo 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 foo | ||
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 foo/foo.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}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <foo/foo.hpp> | ||
|
||
#include <iostream> // std::cout | ||
|
||
namespace foo | ||
{ | ||
|
||
void foo::Run() | ||
{ | ||
std::cout << "foo::Run" << std::endl; | ||
} | ||
|
||
} // namespace foo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef FOO_FOO_HPP_ | ||
#define FOO_FOO_HPP_ | ||
|
||
namespace foo | ||
{ | ||
|
||
class foo | ||
{ | ||
public: | ||
void Run(); | ||
}; | ||
|
||
} // namespace foo | ||
|
||
#endif // FOO_FOO_HPP_ |