Skip to content

Commit 422a9db

Browse files
authored
Merge pull request #6 from arijitsh/master
update cmake to export as library
2 parents 0079143 + bad5007 commit 422a9db

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

CMakeLists.txt

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,3 +446,62 @@ add_custom_target(uninstall
446446
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
447447
DEPENDS uninstall_pycyrptosat
448448
)
449+
450+
# -----------------------------------------------------------------------------
451+
# Export our targets so that other CMake based projects can interface with
452+
# the build of cmsgen in the build-tree
453+
# -----------------------------------------------------------------------------
454+
set(CMSGEN_TARGETS_FILENAME "cmsgenTargets.cmake")
455+
set(CMSGEN_CONFIG_FILENAME "cmsgenConfig.cmake")
456+
set(CMSGEN_VERSION_FILENAME "cmsgenConfigVersion.cmake")
457+
458+
# Export targets
459+
set(MY_TARGETS cmsgen)
460+
export(
461+
TARGETS ${MY_TARGETS}
462+
FILE "${CMAKE_CURRENT_BINARY_DIR}/${CMSGEN_TARGETS_FILENAME}"
463+
)
464+
465+
466+
# Create cmsgenConfig file
467+
set(EXPORT_TYPE "Build-tree")
468+
set(CONF_INCLUDE_DIRS "${CMAKE_CURRENT_BINARY_DIR}/include")
469+
configure_file(cmsgenConfig.cmake.in
470+
"${CMAKE_CURRENT_BINARY_DIR}/${CMSGEN_CONFIG_FILENAME}" @ONLY
471+
)
472+
473+
# Export this package to the CMake user package registry
474+
# Now the user can just use find_package(cmsgen) on their system
475+
export(PACKAGE cmsgen)
476+
477+
set(DEF_INSTALL_CMAKE_DIR lib/cmake/cmsgen)
478+
set(CMSGEN_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH
479+
"Installation directory for cmsgen CMake files")
480+
481+
# Create cmsgenConfig file
482+
set(EXPORT_TYPE "installed")
483+
set(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include")
484+
configure_file(cmsgenConfig.cmake.in
485+
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${CMSGEN_CONFIG_FILENAME}" @ONLY
486+
)
487+
488+
include(CMakePackageConfigHelpers)
489+
write_basic_package_version_file(
490+
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${CMSGEN_VERSION_FILENAME}"
491+
COMPATIBILITY SameMajorVersion)
492+
493+
install(FILES
494+
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${CMSGEN_VERSION_FILENAME}"
495+
DESTINATION "${CMSGEN_INSTALL_CMAKE_DIR}"
496+
)
497+
498+
install(FILES
499+
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${CMSGEN_CONFIG_FILENAME}"
500+
DESTINATION "${CMSGEN_INSTALL_CMAKE_DIR}"
501+
)
502+
503+
# Install the export set for use with the install-tree
504+
install(
505+
EXPORT ${CMSGEN_EXPORT_NAME}
506+
DESTINATION "${CMSGEN_INSTALL_CMAKE_DIR}"
507+
)

cmsgenConfig.cmake.in

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Config file for the @EXPORT_TYPE@ cmsgen Package
2+
# It defines the following variables
3+
# CMSGEN_INCLUDE_DIRS - include directories for cmsgen
4+
# CMSGEN_LIBRARIES - libraries to link against
5+
# CMSGEN_EXECUTABLE - the cmsgen executable
6+
7+
# Compute paths
8+
get_filename_component(CMSGEN_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
9+
set(CMSGEN_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
10+
11+
# Our library dependencies (contains definitions for IMPORTED targets)
12+
include("${CMSGEN_CMAKE_DIR}/@CMSGEN_TARGETS_FILENAME@")
13+
14+
# These are IMPORTED targets created by @CMSGEN_TARGETS_FILENAME@
15+
set(CMSGEN_LIBRARIES cmsgen)
16+
set(CMSGEN_STATIC_LIBRARIES cmsgen)
17+
set(CMSGEN_STATIC_LIBRARIES_DEPS @CMSGEN_STATIC_DEPS@)
18+
set(CMSGEN_VERSION_MAJOR @PROJECT_VERSION_MAJOR@)
19+
set(CMSGEN_VERSION_MINOR @PROJECT_VERSION_MINOR@)
20+
set(CMSGEN_EXECUTABLE cmsgen)

0 commit comments

Comments
 (0)