forked from OctoMap/octomap
-
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.
Added pkg-config creation (thx to Abe Bachrach)
- Loading branch information
Armin Hornung
committed
Jun 10, 2011
1 parent
3b89dd5
commit 64d2eec
Showing
2 changed files
with
87 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
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,78 @@ | ||
# A Macro to simplify creating a pkg-config file | ||
|
||
# install_pkg_config_file(<package-name> | ||
# [VERSION <version>] | ||
# [DESCRIPTION <description>] | ||
# [CFLAGS <cflag> ...] | ||
# [LIBS <lflag> ...] | ||
# [REQUIRES <required-package-name> ...]) | ||
# | ||
# Create and install a pkg-config .pc file to CMAKE_INSTALL_PREFIX/lib/pkgconfig | ||
# assuming the following install layout: | ||
# libraries: CMAKE_INSTALL_PREFIX/lib | ||
# headers : CMAKE_INSTALL_PREFIX/include | ||
# | ||
# example: | ||
# add_library(mylib mylib.c) | ||
# install_pkg_config_file(mylib | ||
# DESCRIPTION My Library | ||
# CFLAGS | ||
# LIBS -lmylib | ||
# REQUIRES glib-2.0 lcm | ||
# VERSION 0.0.1) | ||
# | ||
# | ||
function(install_pkg_config_file) | ||
list(GET ARGV 0 pc_name) | ||
# TODO error check | ||
|
||
set(pc_version 0.0.1) | ||
set(pc_description ${pc_name}) | ||
set(pc_requires "") | ||
set(pc_libs "") | ||
set(pc_cflags "") | ||
set(pc_fname "${CMAKE_BINARY_DIR}/lib/pkgconfig/${pc_name}.pc") | ||
|
||
set(modewords LIBS CFLAGS REQUIRES VERSION DESCRIPTION) | ||
set(curmode "") | ||
|
||
# parse function arguments and populate pkg-config parameters | ||
list(REMOVE_AT ARGV 0) | ||
foreach(word ${ARGV}) | ||
list(FIND modewords ${word} mode_index) | ||
if(${mode_index} GREATER -1) | ||
set(curmode ${word}) | ||
elseif(curmode STREQUAL LIBS) | ||
set(pc_libs "${pc_libs} ${word}") | ||
elseif(curmode STREQUAL CFLAGS) | ||
set(pc_cflags "${pc_cflags} ${word}") | ||
elseif(curmode STREQUAL REQUIRES) | ||
set(pc_requires "${pc_requires} ${word}") | ||
elseif(curmode STREQUAL VERSION) | ||
set(pc_version ${word}) | ||
set(curmode "") | ||
elseif(curmode STREQUAL DESCRIPTION) | ||
set(pc_description "${word}") | ||
set(curmode "") | ||
else(${mode_index} GREATER -1) | ||
message("WARNING incorrect use of install_pkg_config_file (${word})") | ||
break() | ||
endif(${mode_index} GREATER -1) | ||
endforeach(word) | ||
|
||
# write the .pc file out | ||
file(WRITE ${pc_fname} | ||
"prefix=${CMAKE_INSTALL_PREFIX}\n" | ||
"libdir=\${prefix}/lib\n" | ||
"includedir=\${prefix}/include\n" | ||
"\n" | ||
"Name: ${pc_name}\n" | ||
"Description: ${pc_description}\n" | ||
"Requires: ${pc_requires}\n" | ||
"Version: ${pc_version}\n" | ||
"Libs: -L\${libdir} ${pc_libs}\n" | ||
"Cflags: -I\${includedir} ${pc_cflags}\n") | ||
|
||
# mark the .pc file for installation to the lib/pkgconfig directory | ||
install(FILES ${pc_fname} DESTINATION lib/pkgconfig) | ||
endfunction(install_pkg_config_file) |