Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

fix build error when Boost CONFIG_MACRO is the last of the CMAKE_ARGS #1220

Merged
merged 12 commits into from Nov 24, 2017
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions cmake/modules/hunter_parse_boost_config_macros.cmake
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.0)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, we will inherit policies from parent.


function(hunter_parse_boost_config_macros outvar)
# parse ARGN to convert 'CONFIG_MACRO=id1;id2;CONFIG_MACRO_id3=3' to 'id1;id2;id3=3'
unset(boost_config_macros_list)
set(config_macros_without_value_mode FALSE)
foreach(arg in ${ARGN})
if ("${arg}" MATCHES "[^=]+=.+")
set(config_macros_without_value_mode FALSE)
endif()
if(config_macros_without_value_mode)
# CONFIG_MACRO=id_1 id_2 ... id_n -> APPEND id_n
list(APPEND boost_config_macros_list "${arg}")
elseif("${arg}" MATCHES "^CONFIG_MACRO=(.+)" )
# CONFIG_MACRO=id_1 id_2 ... id_n -> APPEND id_1
list(APPEND boost_config_macros_list "${CMAKE_MATCH_1}")
set(config_macros_without_value_mode TRUE)
elseif("${arg}" MATCHES "^CONFIG_MACRO_([^=]+=.+)" )
# CONFIG_MACRO_id=val -> APPEND id=val
list(APPEND boost_config_macros_list "${CMAKE_MATCH_1}")
endif()
endforeach()
set(${outvar} ${boost_config_macros_list} PARENT_SCOPE)
endfunction(hunter_parse_boost_config_macros)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use endfunction().

2 changes: 1 addition & 1 deletion cmake/projects/Boost/atomic/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
atomic
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/chrono/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
chrono
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/context/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
context
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/coroutine/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
coroutine
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/date_time/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
date_time
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/exception/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
exception
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/filesystem/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
filesystem
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/graph/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
graph
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/graph_parallel/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
graph_parallel
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/hunter.cmake
Expand Up @@ -280,4 +280,4 @@ hunter_add_version(

hunter_pick_scheme(DEFAULT url_sha1_boost)
hunter_cacheable(Boost)
hunter_download(PACKAGE_NAME Boost PACKAGE_INTERNAL_DEPS_ID "18")
hunter_download(PACKAGE_NAME Boost PACKAGE_INTERNAL_DEPS_ID "19")
2 changes: 1 addition & 1 deletion cmake/projects/Boost/hunter.cmake.in
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
boost_component
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/iostreams/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
iostreams
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/locale/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
locale
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/log/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
log
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/math/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
math
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/mpi/hunter.cmake
Expand Up @@ -26,5 +26,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
mpi
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/program_options/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
program_options
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/python/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
python
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/random/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
random
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/regex/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
regex
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
9 changes: 6 additions & 3 deletions cmake/projects/Boost/schemes/url_sha1_boost.cmake.in
Expand Up @@ -17,6 +17,7 @@ include(hunter_status_debug)
include(hunter_status_print)
include(hunter_test_string_not_empty)
include(hunter_user_error)
include(hunter_parse_boost_config_macros)

hunter_status_debug("Scheme: url_sha1_boost")

Expand Down Expand Up @@ -95,6 +96,8 @@ else()
set(log_opts "")
endif()

hunter_parse_boost_config_macros(boost_config_macros_list "@HUNTER_Boost_CMAKE_ARGS@")

ExternalProject_Add(
"@HUNTER_EP_NAME@"
URL
Expand All @@ -109,9 +112,9 @@ ExternalProject_Add(
"@HUNTER_PACKAGE_INSTALL_PREFIX@"
# not used, just avoid creating Install/<name> empty directory
UPDATE_COMMAND
"@CMAKE_COMMAND@" -P
"@HUNTER_GLOBAL_SCRIPT_DIR@/append-boost-config-macros.cmake"
"@HUNTER_Boost_CMAKE_ARGS@"
"@CMAKE_COMMAND@"
"-DBOOST_CONFIG_MACROS=${boost_config_macros_list}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

examples/Boost-custom-args is not working.

This line converted to -DBOOST_CONFIG_MACROS=BOOST_1 BOOST_2 BOOST_3=5 (3 arguments, 2 ignored) instead of -DBOOST_CONFIG_MACROS=BOOST_1;BOOST_2;BOOST_3=5 (1 argument). It's better to use configure_file to create script.

-P "@HUNTER_GLOBAL_SCRIPT_DIR@/append-boost-config-macros.cmake"
CONFIGURE_COMMAND
${env_cmd}
COMMAND
Expand Down
Expand Up @@ -18,6 +18,7 @@ include(hunter_status_debug)
include(hunter_test_string_not_empty)
include(hunter_unsetvar)
include(hunter_get_boost_libs)
include(hunter_parse_boost_config_macros)

hunter_status_debug("Scheme: url_sha1_boost_ios_library")

Expand Down Expand Up @@ -296,6 +297,8 @@ else()
set(extra_lib_command "")
endif()

hunter_parse_boost_config_macros(boost_config_macros_list "@HUNTER_Boost_CMAKE_ARGS@")

ExternalProject_Add(
"@HUNTER_EP_NAME@-ios_universal"
DEPENDS
Expand All @@ -311,9 +314,9 @@ ExternalProject_Add(
"@HUNTER_PACKAGE_INSTALL_PREFIX@"
# not used, just avoid creating Install/<name> empty directory
UPDATE_COMMAND
"@CMAKE_COMMAND@" -P
"@HUNTER_GLOBAL_SCRIPT_DIR@/append-boost-config-macros.cmake"
"@HUNTER_Boost_CMAKE_ARGS@"
"@CMAKE_COMMAND@"
"-DBOOST_CONFIG_MACROS=${boost_config_macros_list}"
-P "@HUNTER_GLOBAL_SCRIPT_DIR@/append-boost-config-macros.cmake"
CONFIGURE_COMMAND
""
BUILD_COMMAND
Expand Down
9 changes: 6 additions & 3 deletions cmake/projects/Boost/schemes/url_sha1_boost_library.cmake.in
Expand Up @@ -23,6 +23,7 @@ include(hunter_status_debug)
include(hunter_status_print)
include(hunter_test_string_not_empty)
include(hunter_user_error)
include(hunter_parse_boost_config_macros)

hunter_status_debug("Scheme: url_sha1_boost_library")

Expand Down Expand Up @@ -350,6 +351,8 @@ else()
set(log_opts "")
endif()

hunter_parse_boost_config_macros(boost_config_macros_list "@HUNTER_Boost_CMAKE_ARGS@")

ExternalProject_Add(
"@HUNTER_EP_NAME@"
URL
Expand All @@ -364,9 +367,9 @@ ExternalProject_Add(
"@HUNTER_PACKAGE_INSTALL_PREFIX@"
# not used, just avoid creating Install/<name> empty directory
UPDATE_COMMAND
"@CMAKE_COMMAND@" -P
"@HUNTER_GLOBAL_SCRIPT_DIR@/append-boost-config-macros.cmake"
"@HUNTER_Boost_CMAKE_ARGS@"
"@CMAKE_COMMAND@"
"-DBOOST_CONFIG_MACROS=${boost_config_macros_list}"
-P "@HUNTER_GLOBAL_SCRIPT_DIR@/append-boost-config-macros.cmake"
CONFIGURE_COMMAND
${env_cmd}
${copy_mpi_command}
Expand Down
2 changes: 1 addition & 1 deletion cmake/projects/Boost/serialization/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
serialization
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/signals/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
signals
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/system/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
system
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/test/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
test
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/thread/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
thread
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/timer/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
timer
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
2 changes: 1 addition & 1 deletion cmake/projects/Boost/wave/hunter.cmake
Expand Up @@ -18,5 +18,5 @@ hunter_download(
Boost
PACKAGE_COMPONENT
wave
PACKAGE_INTERNAL_DEPS_ID "18"
PACKAGE_INTERNAL_DEPS_ID "19"
)
26 changes: 4 additions & 22 deletions scripts/append-boost-config-macros.cmake
Expand Up @@ -3,33 +3,15 @@ cmake_minimum_required(VERSION 3.0)
# run at the boost source root
set(boost_user_config_file "boost/config/user.hpp")

set(define_without_value_mode FALSE)

foreach(i RANGE ${CMAKE_ARGC})

if (define_without_value_mode)
if ("${CMAKE_ARGV${i}}" MATCHES "[^=]+=.+")
set(define_without_value_mode FALSE)
endif()
endif()

foreach(s ${BOOST_CONFIG_MACROS})
unset(append_str)

if(define_without_value_mode)
# CONFIG_MACRO=id_1 id_2 ... id_n -> #define id_n
set(append_str "#define ${CMAKE_ARGV${i}}")
elseif("${CMAKE_ARGV${i}}" MATCHES "^CONFIG_MACRO=(.+)" )
# CONFIG_MACRO=id_1 id_2 ... id_n -> #define id_1
set(append_str "#define ${CMAKE_MATCH_1}")
set(define_without_value_mode TRUE)
elseif("${CMAKE_ARGV${i}}" MATCHES "^CONFIG_MACRO_([^=]+)=(.+)" )
# CONFIG_MACRO_id=val -> #define id val
if("${s}" MATCHES "^([^=]+)=(.+)" )
set(append_str "#define ${CMAKE_MATCH_1} ${CMAKE_MATCH_2}")
else()
set(append_str "#define ${s}")
endif()

if(append_str)
message("-- append '${append_str}' to '${boost_user_config_file}'")
file(APPEND "${boost_user_config_file}" "\n${append_str}\n")
endif()

endforeach()