Skip to content

Commit e5d335c

Browse files
committed
collect cflags and libs values
1 parent 29400f0 commit e5d335c

File tree

5 files changed

+46
-4
lines changed

5 files changed

+46
-4
lines changed

Makefile.PL

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use ExtUtils::MakeMaker;
22
use strict;
33
use warnings;
44

5+
# ignore system library, force a build from source code
56
BEGIN { $ENV{ALIEN_INSTALL_TYPE} = 'share'; }
67

78
use File::Spec;

alienfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,16 @@ share {
4444
'%{make} install',
4545
];
4646
plugin 'Gather::IsolateDynamic';
47+
# save correct package settings
48+
# for now there is no good way to retrieve them from cmake
49+
gather sub {
50+
my ( $build ) = @_;
51+
my $prefix = $build->runtime_prop->{prefix};
52+
$build->runtime_prop->{cflags} = "-I$prefix/include";
53+
$build->runtime_prop->{cflags_static} = "-I$prefix/include";
54+
my $extra_libs = ' -lm';
55+
$extra_libs .= ' -lshlwapi' if $^O eq 'MSWin32';
56+
$build->runtime_prop->{libs} = "-L$prefix/lib -ljq -lonig". $extra_libs;
57+
$build->runtime_prop->{libs_static} = "-L$prefix/lib -ljq -lonig". $extra_libs;
58+
};
4759
};

jq/CMakeLists.txt

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,40 @@ endif()
438438
if(ENABLE_DOCS)
439439
endif()
440440

441-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jq.pc.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/jq.pc @ONLY)
442441

443442
# TODO: support full packaging
444443
install_library(jq)
445444
install_executable(jq_bin)
446445
install_header(src/jv.h src/jq.h)
447446
install_data(AUTHORS COPYING NEWS README)
448-
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jq.pc DESTINATION lib/pkgconfig)
447+
448+
# export cmake configurations
449+
install(TARGETS jq onig EXPORT jqTargets)
450+
install(EXPORT jqTargets FILE jqTargets.cmake DESTINATION lib/cmake/jq)
451+
include(CMakePackageConfigHelpers)
452+
# generate the config file that includes the exports
453+
configure_package_config_file(
454+
${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
455+
${CMAKE_CURRENT_BINARY_DIR}/jqConfig.cmake
456+
INSTALL_DESTINATION lib/cmake/jq
457+
NO_SET_AND_CHECK_MACRO
458+
NO_CHECK_REQUIRED_COMPONENTS_MACRO
459+
)
460+
# generate the version file for the config file
461+
write_basic_package_version_file(
462+
${CMAKE_CURRENT_BINARY_DIR}/jqConfigVersion.cmake
463+
VERSION ${PACKAGE_VERSION}
464+
COMPATIBILITY AnyNewerVersion
465+
)
466+
# install the configuration file
467+
install(FILES
468+
${CMAKE_CURRENT_BINARY_DIR}/jqConfig.cmake
469+
${CMAKE_CURRENT_BINARY_DIR}/jqConfigVersion.cmake
470+
DESTINATION lib/cmake/jq
471+
)
472+
473+
# information in legacy pkgconfig is wrong/missing
474+
#configure_file(${CMAKE_CURRENT_SOURCE_DIR}/jq.pc.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/jq.pc @ONLY)
475+
#install(FILES ${CMAKE_CURRENT_BINARY_DIR}/jq.pc DESTINATION lib/pkgconfig)
476+
477+
#export(EXPORT jqTargets FILE ${CMAKE_CURRENT_BINARY_DIR}/jqTargets.cmake)

jq/jq.pc.cmake.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ Name: jq
99
Description: lightweight and flexible command-line JSON processor
1010
Version: @PACKAGE_VERSION@
1111
Requires:
12-
Libs: -L${libdir} -ljq -lonig
12+
Libs: -L${libdir} -ljq -lonig -lm
1313
Cflags: -I${includedir}

lib/Alien/LibJQ.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use warnings;
44
use base qw/Alien::Base/;
55
use vars qw/$VERSION/;
66

7-
$VERSION = '0.01';
7+
$VERSION = '0.02';
88

99
=head1 NAME
1010

0 commit comments

Comments
 (0)