score icon indicating copy to clipboard operation
score copied to clipboard

cmake finds the concurrentqueue package but the C++ compiler then fails to find blockingconcurrentqueue.h

Open yurivict opened this issue 9 months ago • 1 comments

In file included from /usr/ports/multimedia/ossia-score/work/.build/3rdparty/libossia/src/CMakeFiles/ossia.dir/Unity/unity_0_cxx.cxx:76:
In file included from /usr/ports/multimedia/ossia-score/work/ossia-score-3.4.1/3rdparty/libossia/src/ossia/network/common/device_parameter.cpp:2:
In file included from /usr/ports/multimedia/ossia-score/work/ossia-score-3.4.1/3rdparty/libossia/src/ossia/network/common/device_parameter.hpp:7:
In file included from /usr/ports/multimedia/ossia-score/work/ossia-score-3.4.1/3rdparty/libossia/src/ossia/network/oscquery/oscquery_server.hpp:2:
/usr/ports/multimedia/ossia-score/work/ossia-score-3.4.1/3rdparty/libossia/src/ossia/detail/lockfree_queue.hpp:6:10: fatal error: 'blockingconcurrentqueue.h' file not found
    6 | #include <blockingconcurrentqueue.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

The concurrentqueue package installs cmake scripts and the paths set by them should be used during build.

Version: 3.4.1 concurrentqueue-1.0.4 clang-19

yurivict avatar Feb 18 '25 20:02 yurivict

hmmm, ossia is already linking against the CMake target though ?

here we do a find_package: https://github.com/ossia/libossia/blob/master/cmake/deps/concurrentqueue.cmake#L2

here we link against it: https://github.com/ossia/libossia/blob/master/src/ossia_setup.cmake#L171

there shouldn't be anything else to do to get the include paths

jcelerier avatar Apr 10 '25 02:04 jcelerier

i got a little bit further with this:

    64  12:15   cd /usr/local/include/concurrentqueue/
    65  12:15   ll               <---- thinking to myself "wtf" at this point
    66  12:15   ll moodycamel/
    67  12:16   ln -s moodycamel/blockingconcurrentqueue.h ./
    68  12:16   ln -s moodycamel/concurrentqueue.h ./
    69  12:16   ln -s moodycamel/lightweightsemaphore.h ./

im not sure whether that means multimedia/ossia-score is looking in the wrong place or concurrentqueue is getting packaged wrong atm

NatUni avatar Jul 09 '25 19:07 NatUni

could you share the concurrentqueue package's files ? I can check if the paths in the concurrentqueue-Config.cmake make sense

jcelerier avatar Jul 10 '25 13:07 jcelerier

concurrentqueue-1.0.4:
  /usr/local/include/concurrentqueue/blockingconcurrentqueue.h <- i added these 3
  /usr/local/include/concurrentqueue/concurrentqueue.h         <- symlinks. they
  /usr/local/include/concurrentqueue/lightweightsemaphore.h    <- point to here
  /usr/local/include/concurrentqueue/moodycamel/LICENSE.md                   |
  /usr/local/include/concurrentqueue/moodycamel/blockingconcurrentqueue.h  <-|
  /usr/local/include/concurrentqueue/moodycamel/concurrentqueue.h          <-|
  /usr/local/include/concurrentqueue/moodycamel/lightweightsemaphore.h     <-'
  /usr/local/lib/cmake/concurrentqueue/concurrentqueueConfig.cmake
  /usr/local/lib/cmake/concurrentqueue/concurrentqueueConfigVersion.cmake
  /usr/local/lib/cmake/concurrentqueue/concurrentqueueTargets.cmake
  /usr/local/share/licenses/concurrentqueue-1.0.4/BSD2CLAUSE
  /usr/local/share/licenses/concurrentqueue-1.0.4/LICENSE
  /usr/local/share/licenses/concurrentqueue-1.0.4/catalog.mk

that let me build ossia-score 3.4.1 where before it was failing

NatUni avatar Jul 10 '25 21:07 NatUni

thanks! if you could share these following files too:

/usr/local/lib/cmake/concurrentqueue/concurrentqueueConfig.cmake /usr/local/lib/cmake/concurrentqueue/concurrentqueueConfigVersion.cmake /usr/local/lib/cmake/concurrentqueue/concurrentqueueTargets.cmake

jcelerier avatar Jul 11 '25 02:07 jcelerier

sure bud. thanks for looking into all this for us

concurrentqueueConfig.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 concurrentqueueConfig.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(${CMAKE_CURRENT_LIST_DIR}/concurrentqueueTargets.cmake)

concurrentqueueConfigVersion.cmake:

# This is a basic version file for the Config-mode of find_package().
# It is used by write_basic_package_version_file() as input file for configure_file()
# to create a version-file which can be installed along a config.cmake file.
#
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
# the requested version string are exactly the same and it sets
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version.
# The variable CVF_VERSION must be set before calling configure_file().

set(PACKAGE_VERSION "1.0.0")

if (PACKAGE_FIND_VERSION_RANGE)
  # Package version must be in the requested version range
  if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN)
      OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX)
        OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX)))
    set(PACKAGE_VERSION_COMPATIBLE FALSE)
  else()
    set(PACKAGE_VERSION_COMPATIBLE TRUE)
  endif()
else()
  if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
    set(PACKAGE_VERSION_COMPATIBLE FALSE)
  else()
    set(PACKAGE_VERSION_COMPATIBLE TRUE)
    if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
      set(PACKAGE_VERSION_EXACT TRUE)
    endif()
  endif()
endif()


# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
  return()
endif()

# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
  math(EXPR installedBits "8 * 8")
  set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
  set(PACKAGE_VERSION_UNSUITABLE TRUE)
endif()

concurrentqueueTargets.cmake:

# Generated by CMake

if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8)
   message(FATAL_ERROR "CMake >= 3.0.0 required")
endif()
if(CMAKE_VERSION VERSION_LESS "3.0.0")
   message(FATAL_ERROR "CMake >= 3.0.0 required")
endif()
cmake_policy(PUSH)
cmake_policy(VERSION 3.0.0...3.29)
#----------------------------------------------------------------
# Generated CMake target import file.
#----------------------------------------------------------------

# Commands may need to know the format version.
set(CMAKE_IMPORT_FILE_VERSION 1)

# Protect against multiple inclusion, which would fail when already imported targets are added once more.
set(_cmake_targets_defined "")
set(_cmake_targets_not_defined "")
set(_cmake_expected_targets "")
foreach(_cmake_expected_target IN ITEMS concurrentqueue::concurrentqueue)
  list(APPEND _cmake_expected_targets "${_cmake_expected_target}")
  if(TARGET "${_cmake_expected_target}")
    list(APPEND _cmake_targets_defined "${_cmake_expected_target}")
  else()
    list(APPEND _cmake_targets_not_defined "${_cmake_expected_target}")
  endif()
endforeach()
unset(_cmake_expected_target)
if(_cmake_targets_defined STREQUAL _cmake_expected_targets)
  unset(_cmake_targets_defined)
  unset(_cmake_targets_not_defined)
  unset(_cmake_expected_targets)
  unset(CMAKE_IMPORT_FILE_VERSION)
  cmake_policy(POP)
  return()
endif()
if(NOT _cmake_targets_defined STREQUAL "")
  string(REPLACE ";" ", " _cmake_targets_defined_text "${_cmake_targets_defined}")
  string(REPLACE ";" ", " _cmake_targets_not_defined_text "${_cmake_targets_not_defined}")
  message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_cmake_targets_defined_text}\nTargets not yet defined: ${_cmake_targets_not_defined_text}\n")
endif()
unset(_cmake_targets_defined)
unset(_cmake_targets_not_defined)
unset(_cmake_expected_targets)


# Compute the installation prefix relative to this file.
get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH)
if(_IMPORT_PREFIX STREQUAL "/")
  set(_IMPORT_PREFIX "")
endif()

# Create imported target concurrentqueue::concurrentqueue
add_library(concurrentqueue::concurrentqueue INTERFACE IMPORTED)

set_target_properties(concurrentqueue::concurrentqueue PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/concurrentqueue/"
)

# Load information for each installed configuration.
file(GLOB _cmake_config_files "${CMAKE_CURRENT_LIST_DIR}/concurrentqueueTargets-*.cmake")
foreach(_cmake_config_file IN LISTS _cmake_config_files)
  include("${_cmake_config_file}")
endforeach()
unset(_cmake_config_file)
unset(_cmake_config_files)

# Cleanup temporary variables.
set(_IMPORT_PREFIX)

# Loop over all imported files and verify that they actually exist
foreach(_cmake_target IN LISTS _cmake_import_check_targets)
  if(CMAKE_VERSION VERSION_LESS "3.28"
      OR NOT DEFINED _cmake_import_check_xcframework_for_${_cmake_target}
      OR NOT IS_DIRECTORY "${_cmake_import_check_xcframework_for_${_cmake_target}}")
    foreach(_cmake_file IN LISTS "_cmake_import_check_files_for_${_cmake_target}")
      if(NOT EXISTS "${_cmake_file}")
        message(FATAL_ERROR "The imported target \"${_cmake_target}\" references the file
   \"${_cmake_file}\"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   \"${CMAKE_CURRENT_LIST_FILE}\"
but not all the files it references.
")
      endif()
    endforeach()
  endif()
  unset(_cmake_file)
  unset("_cmake_import_check_files_for_${_cmake_target}")
endforeach()
unset(_cmake_target)
unset(_cmake_import_check_targets)

# This file does not depend on other imported targets which have
# been exported from the same project but in a separate export set.

# Commands beyond this point should not need to know the version.
set(CMAKE_IMPORT_FILE_VERSION)
cmake_policy(POP)

NatUni avatar Jul 11 '25 05:07 NatUni

ok, so the package looks for

set_target_properties(concurrentqueue::concurrentqueue PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/concurrentqueue/"
)

but the package installs them in ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/moodycamel

install(
        FILES 
                blockingconcurrentqueue.h 
                concurrentqueue.h 
                lightweightsemaphore.h 
                LICENSE.md
        DESTINATION 
                ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/moodycamel
)

https://github.com/cameron314/concurrentqueue/blob/master/CMakeLists.txt#L55

which differs from the structure of the source repo and the example provided here: https://github.com/cameron314/concurrentqueue/blob/c68072129c8a5b4025122ca5a0c82ab14b30cb03/README.md?plain=1#L103

I think the simplest fix would be to add:

 target_include_directories(
            $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/moodycamel>
 )

here: https://github.com/cameron314/concurrentqueue/blob/c68072129c8a5b4025122ca5a0c82ab14b30cb03/CMakeLists.txt#L12

so that people can include through <concurrentqueue.h> as per the docs of the project, or <moodycamel/concurrentqueue.h> as per what the CMake script seem to want

jcelerier avatar Jul 11 '25 16:07 jcelerier

I added a hotfix in the ossia cmake code but ideally the fix would be upstream in concurrentqueue package

jcelerier avatar Jul 18 '25 16:07 jcelerier