Skip to content

Commit 3dae9d6

Browse files
committed
Status of LibCXX is now validated in version checker
Because autowiring_USE_LIBCXX affects whether or not the requested version is compilable by a client, we now allow a client to specify this flag before invoking find_package in order to assess compatibility of the client's request with the version of autowiring identified. This is a necessary first step to getting side-by-side installations of Autowiring.
1 parent 2014b3b commit 3dae9d6

File tree

5 files changed

+29
-13
lines changed

5 files changed

+29
-13
lines changed

CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ if(EXTERNAL_LIBRARY_DIR)
1616
list(APPEND CMAKE_INCLUDE_PATH ${EXTERNAL_LIBRARY_DIR})
1717
endif()
1818

19-
# Offer option for USE_LIBCXX only if not defined by enclosing project
20-
# Check for existing definition of USE_LIBCXX
21-
if(NOT DEFINED USE_LIBCXX)
22-
option(USE_LIBCXX "Build Autowiring using c++11" ON)
19+
# Offer option for autowiring_USE_LIBCXX only if not defined by enclosing project
20+
# Check for existing definition of autowiring_USE_LIBCXX
21+
if(NOT DEFINED autowiring_USE_LIBCXX)
22+
option(autowiring_USE_LIBCXX "Build Autowiring using c++11" ON)
2323
else()
24-
if(NOT USE_LIBCXX)
25-
message("Parent project has set USE_LIBCXX = OFF -> Build Autowiring using c++98")
24+
if(NOT autowiring_USE_LIBCXX)
25+
message("Parent project has set autowiring_USE_LIBCXX = OFF -> Build Autowiring using c++98")
2626
endif()
2727
endif()
2828

2929
if(NOT WIN32)
3030
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
3131
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libstdc++")
3232
endif()
33-
if(USE_LIBCXX)
33+
if(autowiring_USE_LIBCXX)
3434
# Clang needs special additional flags to build with C++11
3535
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
3636
# Apple needs us to tell it that we're using libc++, or it will try to use libstdc++ instead

autowiring-configVersion.cmake.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,22 @@ if(NOT ${CMAKE_SIZEOF_VOID_P} STREQUAL @CMAKE_SIZEOF_VOID_P@)
77
return()
88
endif()
99

10+
# Determine whether the user's request (either implied or explicit) for libstdc++ can
11+
# be met by this verison of Autowiring
12+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
13+
# If this value isn't defined, then we assume the user's request is "on"
14+
if(NOT DEFINED autowiring_USE_LIBCXX)
15+
SET(autowiring_USE_LIBCXX ON)
16+
endif()
17+
18+
# Our built version must be the same as the requested version. If it's not, then we are
19+
# not a match for the user's request
20+
if((NOT ${autowiring_USE_LIBCXX} AND @autowiring_USE_LIBCXX@) OR (${autowiring_USE_LIBCXX} AND NOT @autowiring_USE_LIBCXX@))
21+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
22+
set(PACKAGE_VERSION_UNSUITABLE TRUE)
23+
endif()
24+
endif()
25+
1026
# Check whether the requested PACKAGE_FIND_VERSION is compatible
1127
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
1228
set(PACKAGE_VERSION_COMPATIBLE FALSE)

src/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ include_directories(
66
${PROJECT_SOURCE_DIR}/src/autotesting
77
)
88

9-
# The boost C++11 shim is required when building without USE_LIBCXX
10-
if(NOT USE_LIBCXX)
9+
# The boost C++11 shim is required when building without autowiring_USE_LIBCXX
10+
if(NOT autowiring_USE_LIBCXX)
1111
find_package(Boost COMPONENTS thread atomic chrono system date_time QUIET)
1212

1313
if (NOT Boost_FOUND)
14-
message(FATAL_ERROR "Boost is required when building without USE_LIBCXX")
14+
message(FATAL_ERROR "Boost is required when building without autowiring_USE_LIBCXX")
1515
endif()
1616

1717
include_directories(${Boost_INCLUDE_DIR})

src/autowiring/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ target_include_directories(Autowiring INTERFACE
216216
)
217217
set_property(TARGET Autowiring PROPERTY FOLDER "Autowiring")
218218

219-
# The boost C++11 shim is required when building without USE_LIBCXX
220-
if(NOT USE_LIBCXX)
219+
# The boost C++11 shim is required when building without autowiring_USE_LIBCXX
220+
if(NOT autowiring_USE_LIBCXX)
221221
find_package(Boost COMPONENTS thread atomic chrono system date_time QUIET)
222222
target_link_libraries(Autowiring ${Boost_LIBRARIES})
223223
endif()

src/autowiring/test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ set(AutowiringTest_SRCS
5555
UuidTest.cpp
5656
)
5757

58-
if(USE_LIBCXX)
58+
if(autowiring_USE_LIBCXX)
5959
set(AutowiringTest_SRCS ${AutowiringTest_SRCS}
6060
AutoFilterFunctionTest.cpp
6161
AutoFilterPipeTest.cpp

0 commit comments

Comments
 (0)