-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Create a jsoncppConfig.cmake file, even if building under meson #1486
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
0ca7385
1e41177
010540b
fffa351
ec70b8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@PACKAGE_INIT@ | ||
|
||
@MESON_SHARED_TARGET@ | ||
@MESON_STATIC_TARGET@ | ||
|
||
include ( "${CMAKE_CURRENT_LIST_DIR}/jsoncpp-namespaced-targets.cmake" ) | ||
|
||
check_required_components(JsonCpp) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ project( | |
'cpp_std=c++11', | ||
'warning_level=1'], | ||
license : 'Public Domain', | ||
meson_version : '>= 0.49.0') | ||
meson_version : '>= 0.54.0') | ||
|
||
|
||
jsoncpp_headers = files([ | ||
|
@@ -62,6 +62,43 @@ import('pkgconfig').generate( | |
filebase : 'jsoncpp', | ||
description : 'A C++ library for interacting with JSON') | ||
|
||
cmakeconf = configuration_data() | ||
cmakeconf.set('MESON_LIB_DIR', get_option('libdir')) | ||
cmakeconf.set('MESON_INCLUDE_DIR', get_option('includedir')) | ||
|
||
fs = import('fs') | ||
if get_option('default_library') == 'shared' | ||
shared_name = fs.name(jsoncpp_lib.full_path()) | ||
endif | ||
if get_option('default_library') == 'static' | ||
static_name = fs.name(jsoncpp_lib.full_path()) | ||
endif | ||
if get_option('default_library') == 'both' | ||
shared_name = fs.name(jsoncpp_lib.get_shared_lib().full_path()) | ||
static_name = fs.name(jsoncpp_lib.get_static_lib().full_path()) | ||
endif | ||
|
||
if get_option('default_library') == 'shared' or get_option('default_library') == 'both' | ||
cmakeconf.set('MESON_SHARED_TARGET', ''' | ||
add_library(jsoncpp_lib IMPORTED SHARED) | ||
set_target_properties(jsoncpp_lib PROPERTIES | ||
IMPORTED_LOCATION "${PACKAGE_PREFIX_DIR}/''' + get_option('libdir') + '/' + shared_name + '''" | ||
INTERFACE_INCLUDE_DIRECTORIES "${PACKAGE_PREFIX_DIR}/''' + get_option('includedir') + '")') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd suggest using meson's |
||
endif | ||
if get_option('default_library') == 'static' or get_option('default_library') == 'both' | ||
cmakeconf.set('MESON_STATIC_TARGET', ''' | ||
add_library(jsoncpp_static IMPORTED STATIC) | ||
set_target_properties(jsoncpp_static PROPERTIES | ||
IMPORTED_LOCATION "${PACKAGE_PREFIX_DIR}/''' + get_option('libdir') + '/' + static_name + '''" | ||
INTERFACE_INCLUDE_DIRECTORIES "${PACKAGE_PREFIX_DIR}/''' + get_option('includedir') + '")') | ||
endif | ||
|
||
import('cmake').configure_package_config_file( | ||
name: 'jsoncpp', | ||
input: 'jsoncppConfig.cmake.meson.in', | ||
configuration: cmakeconf) | ||
install_data('jsoncpp-namespaced-targets.cmake', install_dir : get_option('libdir') + '/cmake/' + jsoncpp_lib.name()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd use join_paths here too. |
||
|
||
# for libraries bundling jsoncpp | ||
jsoncpp_dep = declare_dependency( | ||
include_directories : jsoncpp_include_directories, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fs module is available since 0.53.0, am I overlooking something else that needs 0.54.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure -- when i ran the build meson complained that I should be requiring 0.54.0
I'll do another commit (for the join_paths suggestion, thanks!) and try 0.53.0 then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case it's probably correct -- I haven't checked out the PR and tried it myself -- it should list which feature requires 0.54 though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the 'name' member function was introduced in 0.54.0