systemc icon indicating copy to clipboard operation
systemc copied to clipboard

SystemCLanguageTargets.cmake placed in wrong directory when using CMake FetchContent with SystemC

Open Jench2103 opened this issue 1 year ago • 1 comments

Hi, I encountered a problem while using the CMake FetchContent to set up SystemC as a dependency library of my project.

Once a clean build finishes, the SystemCLanguageTargets.cmake is put in an incorrect location (i.e., build/) rather than the folder expected by build/_deps/systemclanguage-build/SystemCLanguageConfig.cmake (i.e., build/_deps/systemclanguage-build/). I expect the SystemCLanguageTargets.cmake file to be placed in the same folder as SystemCLanguageConfig.cmake.

Note that a clean build can finish without any errors. However, starting from the second time CMake configures the project, the following error occurs:

CMake Error at build/_deps/systemclanguage-build/SystemCLanguageConfig.cmake:44 (include):
  include could not find requested file:

    /home/user/projects/systemc-test/build/_deps/systemclanguage-build/SystemCLanguageTargets.cmake
Call Stack (most recent call first):
  /usr/local/lib/python3.10/dist-packages/cmake/data/share/cmake-3.25/Modules/FetchContent.cmake:1951 (find_package)
  CMakeLists.txt:14 (fetchcontent_makeavailable)

Steps to Reproduce

Here is a simple example for anyone to reproduce the issue.

  • File Structure
    .
    ├── build/
    ├── CMakeLists.txt
    └── main.cc
    
  • CMakeLists.txt
    include(FetchContent)
    
    cmake_minimum_required(VERSION 3.25)
    
    project(test)
    
    fetchcontent_declare(
        SystemCLanguage
        GIT_REPOSITORY https://github.com/accellera-official/systemc.git
        GIT_TAG 3.0.0
        FIND_PACKAGE_ARGS
    )
    
    fetchcontent_makeavailable(SystemCLanguage)
    
    add_executable(test main.cc)
    target_link_libraries(test SystemC::systemc)
    
  • main.cc
    int main() {
    	return 0;
    }
    
  • Commands for a Clean Build
    mkdir build
    cd build
    cmake ..
    cmake --build . -j
    
  • Commands for the Second Configuration (which will result in the above error):
    cd build
    cmake ..
    

Development Environment

  • OS: Ubuntu 22.04
  • Compiler: GCC 11.4.0
  • CMake Version: 3.25.0

Please let me know if more details are needed, or if there's a known workaround.

Jench2103 avatar Oct 06 '24 20:10 Jench2103

thanks for the feedback. The LWG will investigate the issue.

lmailletcontoz avatar Oct 08 '24 15:10 lmailletcontoz