Skip to content
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

Prevents the looking for boost if built without it for dependents #1032

Merged
merged 1 commit into from
Sep 2, 2022
Merged

Prevents the looking for boost if built without it for dependents #1032

merged 1 commit into from
Sep 2, 2022

Conversation

AlexisTM
Copy link

@AlexisTM AlexisTM commented Aug 25, 2022

The library is still using Boost for the dependents and will fail to build if the dependents do not have BOOST installed.

By adding the following to the configured file, we will fix the usage with either looking or not for Boost. (@MSGPACK_USE_BOOST@ will be translated to ON or OFF at configure time)

IF (@MSGPACK_USE_BOOST@)
    find_dependency(Boost REQUIRED)
ENDIF ()

@AlexisTM AlexisTM changed the title Prevent the usage of boost by adding the MSGPACK_NO_BOOST to dependents Prevents the looking for boost if built without it. Aug 31, 2022
@AlexisTM AlexisTM changed the title Prevents the looking for boost if built without it. Prevents the looking for boost if built without it for dependents Aug 31, 2022
@codecov-commenter
Copy link

Codecov Report

Merging #1032 (0b2c6d9) into cpp_master (cef8a6f) will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##           cpp_master    #1032   +/-   ##
===========================================
  Coverage       85.60%   85.60%           
===========================================
  Files              79       79           
  Lines            5023     5023           
===========================================
  Hits             4300     4300           
  Misses            723      723           

@redboltz
Copy link
Contributor

redboltz commented Aug 31, 2022

Thank you for sending and updating the PR.
I tried to search using the words cmake @ @VARIABLE@ @OPTION@ cmake.in etc on google and cmake.org.
But I couldn't find the document.

Could you tell me the link of cmake manual about @MSGPACK_USE_BOOST@ notation?

@AlexisTM
Copy link
Author

AlexisTM commented Aug 31, 2022

Sure! CMake is wonderfully confusing! (And I am far from an expert)

When calling configure_file(...), in this case the equivalent CONFIGURE_PACKAGE_CONFIG_FILE(...), we will configure the msgpack-config.cmake.in file which will then be installed in INSTALL_PREFIX/lib/cmake/msgpackc-cxx/msgpack-config.cmake

The file configuration step will do a search and replace for @VARIABLE@ by their value. In this case, we are setting MSGPACK_USE_BOOST to ON or OFF in the parent thus will be replaced by that value.

This config file is executed by cmake on find_package(msgpack), thus successfully transferring the information "You do not need Boost" to dependents.

After this PR, the config file becomes the following if we built msgpack with MSGPACK_USE_BOOST=OFF

install/lib/cmake/msgpackc-cxx$ cat msgpack-config.cmake

####### Expanded from @PACKAGE_INIT@ by configure_package_config_file() #######
####### Any changes to this file will be overwritten by the next CMake run ####
####### The input file was msgpack-config.cmake.in                            ########

get_filename_component(PACKAGE_PREFIX_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../" ABSOLUTE)

macro(set_and_check _var _file)
  set(${_var} "${_file}")
  if(NOT EXISTS "${_file}")
    message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
  endif()
endmacro()

macro(check_required_components _NAME)
  foreach(comp ${${_NAME}_FIND_COMPONENTS})
    if(NOT ${_NAME}_${comp}_FOUND)
      if(${_NAME}_FIND_REQUIRED_${comp})
        set(${_NAME}_FOUND FALSE)
      endif()
    endif()
  endforeach()
endmacro()

####################################################################################

include(CMakeFindDependencyMacro)

IF (OFF)
    find_dependency(Boost REQUIRED)
ENDIF ()

include("${CMAKE_CURRENT_LIST_DIR}/msgpackc-cxx-targets.cmake")

check_required_components(msgpackc-cxx)

@redboltz redboltz merged commit d5cef62 into msgpack:cpp_master Sep 2, 2022
@redboltz
Copy link
Contributor

redboltz commented Sep 2, 2022

Merged. Thank you!

@AlexisTM
Copy link
Author

AlexisTM commented Sep 2, 2022

You are welcome!

@AlexisTM AlexisTM deleted the feature/prevent_usage_of_boost branch September 2, 2022 07:47
@AlexisTM AlexisTM restored the feature/prevent_usage_of_boost branch September 2, 2022 07:47
@AlexisTM AlexisTM deleted the feature/prevent_usage_of_boost branch March 3, 2023 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants