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 5 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
3 changes: 2 additions & 1 deletion scripts/append-boost-config-macros.cmake
Expand Up @@ -4,8 +4,9 @@ cmake_minimum_required(VERSION 3.0)
set(boost_user_config_file "boost/config/user.hpp")

set(define_without_value_mode FALSE)
math(EXPR ARGC_COUNT ${CMAKE_ARGC}-1)

foreach(i RANGE ${CMAKE_ARGC})
foreach(i RANGE 3 ${ARGC_COUNT})

if (define_without_value_mode)
if ("${CMAKE_ARGV${i}}" MATCHES "[^=]+=.+")
Expand Down
158 changes: 158 additions & 0 deletions tests/append-boost-config-macros/CMakeLists.txt
@@ -0,0 +1,158 @@
cmake_minimum_required(VERSION 3.0)

project(test-append-boost-config-macros-script)

set(HUNTER_GLOBAL_SCRIPT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../scripts")
set(BOOST_CONFIG_ROOT "${CMAKE_CURRENT_BINARY_DIR}/boost/config")
set(BOOST_USER_CONFIG "${BOOST_CONFIG_ROOT}/user.hpp")

function(test_append_boost_config_macros expected_boost_user_config_content)
file(MAKE_DIRECTORY "${BOOST_CONFIG_ROOT}")
file(WRITE "${BOOST_USER_CONFIG}" "")
execute_process(
COMMAND
"${CMAKE_COMMAND}" -P
"${HUNTER_GLOBAL_SCRIPT_DIR}/append-boost-config-macros.cmake"
${ARGN}
WORKING_DIRECTORY
"${CMAKE_CURRENT_BINARY_DIR}"
)
file(READ "${BOOST_USER_CONFIG}" boost_user_config_content)
string(
COMPARE NOTEQUAL
"${boost_user_config_content}"
"${expected_boost_user_config_content}"
diff
)
if(diff)
message(
FATAL_ERROR "TEST FAIL: ${ARGN}\n"
"boost user config content:\n"
"${boost_user_config_content}\n"
"expected:\n"
"${expected_boost_user_config_content}\n"
)
else()
message("TEST PASS: ${ARGN}")
endif()
endfunction(test_append_boost_config_macros)

test_append_boost_config_macros(
[=[

#define BOOST_REGEX_MATCH_EXTRA

#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS

#define BOOST_MPL_LIMIT_LIST_SIZE 3
]=]
CONFIG_MACRO=BOOST_REGEX_MATCH_EXTRA;BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
CONFIG_MACRO_BOOST_MPL_LIMIT_LIST_SIZE=3
)

test_append_boost_config_macros(
[=[

#define BOOST_MPL_LIMIT_LIST_SIZE 3

#define BOOST_REGEX_MATCH_EXTRA

#define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
]=]
CONFIG_MACRO_BOOST_MPL_LIMIT_LIST_SIZE=3
CONFIG_MACRO=BOOST_REGEX_MATCH_EXTRA;BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
)

test_append_boost_config_macros("" "")

test_append_boost_config_macros(
[=[

#define CM1
]=]
CONFIG_MACRO=CM1
)

test_append_boost_config_macros(
[=[

#define CM1

#define CM2
]=]
CONFIG_MACRO=CM1;CM2
)

test_append_boost_config_macros(
[=[

#define CM1

#define CM2
]=]
CONFIG_MACRO=CM1 CM2
)

test_append_boost_config_macros(
[=[

#define CM1 1
]=]
CONFIG_MACRO_CM1=1
)

test_append_boost_config_macros(
[=[

#define CM1 1

#define CM2 1
]=]
CONFIG_MACRO_CM1=1 CONFIG_MACRO_CM2=1
)

test_append_boost_config_macros(
[=[

#define CM3

#define CM4

#define CM1 1

#define CM2 1
]=]
CONFIG_MACRO=CM3;CM4 CONFIG_MACRO_CM1=1 CONFIG_MACRO_CM2=1
)

test_append_boost_config_macros(
[=[

#define CM1 1

#define CM2 1

#define CM3

#define CM4
]=]
CONFIG_MACRO_CM1=1 CONFIG_MACRO_CM2=1 CONFIG_MACRO=CM3;CM4
)

test_append_boost_config_macros(
[=[

#define CM1 1

#define CM2 1

#define CM3

#define CM4

#define CM5
]=]
CONFIG_MACRO_CM1=1 IGNORED1=1 IGNORED2=2 CONFIG_MACRO_CM2=1
CONFIG_MACRO=CM3;CM4 CM5 IGNORED3=3 IGNORED4
)