Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
G
gflags
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
gflags
Commits
3886da50
Commit
3886da50
authored
Nov 24, 2016
by
Andreas Schuh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enh: Add option to add installation to CMake’s package registry
parent
6c0ee003
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
1 deletion
+46
-1
CMakeLists.txt
CMakeLists.txt
+8
-1
utils.cmake
cmake/utils.cmake
+38
-0
No files found.
CMakeLists.txt
View file @
3886da50
...
...
@@ -164,6 +164,8 @@ gflags_define (BOOL BUILD_TESTING "Enable build of the unit tests a
gflags_define
(
BOOL INSTALL_HEADERS
"Request installation of headers and other development files."
ON OFF
)
gflags_define
(
BOOL INSTALL_SHARED_LIBS
"Request installation of shared libraries."
ON ON
)
gflags_define
(
BOOL INSTALL_STATIC_LIBS
"Request installation of static libraries."
ON OFF
)
gflags_define
(
BOOL REGISTER_BUILD_DIR
"Request entry of build directory in CMake's package registry."
OFF OFF
)
gflags_define
(
BOOL REGISTER_INSTALL_PREFIX
"Request entry of installed package in CMake's package registry."
ON OFF
)
gflags_property
(
BUILD_STATIC_LIBS ADVANCED TRUE
)
gflags_property
(
INSTALL_HEADERS ADVANCED TRUE
)
...
...
@@ -523,7 +525,12 @@ endif ()
# support direct use of build tree
set
(
INSTALL_PREFIX_REL2CONFIG_DIR .
)
export
(
TARGETS
${
TARGETS
}
FILE
"
${
PROJECT_BINARY_DIR
}
/
${
EXPORT_NAME
}
.cmake"
)
export
(
PACKAGE gflags
)
if
(
REGISTER_BUILD_DIR
)
export
(
PACKAGE
${
PACKAGE_NAME
}
)
endif
()
if
(
REGISTER_INSTALL_PREFIX
)
register_gflags_package
(
${
CONFIG_INSTALL_DIR
}
)
endif
()
configure_file
(
cmake/config.cmake.in
"
${
PROJECT_BINARY_DIR
}
/
${
PACKAGE_NAME
}
-config.cmake"
@ONLY
)
# ----------------------------------------------------------------------------
...
...
cmake/utils.cmake
View file @
3886da50
...
...
@@ -161,3 +161,41 @@ macro (add_gflags_test name expected_rc expected_output unexpected_output cmd)
WORKING_DIRECTORY
"
${
GFLAGS_FLAGFILES_DIR
}
"
)
endmacro
()
# ------------------------------------------------------------------------------
## Register installed package with CMake
#
# This function adds an entry to the CMake registry for packages with the
# path of the directory where the package configuration file of the installed
# package is located in order to help CMake find the package in a custom
# installation prefix. This differs from CMake's export(PACKAGE) command
# which registers the build directory instead.
function
(
register_gflags_package CONFIG_DIR
)
if
(
NOT IS_ABSOLUTE
"
${
CONFIG_DIR
}
"
)
set
(
CONFIG_DIR
"
${
CMAKE_INSTALL_PREFIX
}
/
${
CONFIG_DIR
}
"
)
endif
()
string
(
MD5 REGISTRY_ENTRY
"
${
CONFIG_DIR
}
"
)
if
(
WIN32
)
install
(
CODE
"execute_process (
COMMAND reg add
\"
HKCU
\\\\
Software
\\\\
Kitware
\\\\
CMake
\\\\
Packages
\\\\
${
PACKAGE_NAME
}
\"
/v
\"
${
REGISTRY_ENTRY
}
\"
/d
\"
${
CONFIG_DIR
}
\"
/t REG_SZ /f
RESULT_VARIABLE RT
ERROR_VARIABLE ERR
OUTPUT_QUIET
)
if (RT EQUAL 0)
message (STATUS
\"
Register: Added HKEY_CURRENT_USER
\\\\
Software
\\\\
Kitware
\\\\
CMake
\\\\
Packages
\\\\
${
PACKAGE_NAME
}
\\\\
${
REGISTRY_ENTRY
}
\"
)
else ()
string (STRIP
\"\$
{ERR}
\"
ERR)
message (STATUS
\"
Register: Failed to add registry entry:
\$
{ERR}
\"
)
endif ()"
)
elseif
(
IS_DIRECTORY
"$ENV{HOME}"
)
file
(
WRITE
"
${
PROJECT_BINARY_DIR
}
/
${
PACKAGE_NAME
}
-registry-entry"
"
${
CONFIG_DIR
}
"
)
install
(
FILES
"
${
PROJECT_BINARY_DIR
}
/
${
PACKAGE_NAME
}
-registry-entry"
DESTINATION
"$ENV{HOME}/.cmake/packages/
${
PACKAGE_NAME
}
"
RENAME
"
${
REGISTRY_ENTRY
}
"
)
endif
()
endfunction
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment