threeal / cmake-action

Configure and build CMake projects on GitHub Actions
https://github.com/marketplace/actions/cmake-action
MIT License
26 stars 2 forks source link

Project deppending on other project not compiling after switching to main #526

Open MartinSalinas98 opened 5 days ago

MartinSalinas98 commented 5 days ago

I collaborate in some C++ projects, and, in one of them, we are recently experienciing compilation issues since we switched the cmake-action we use from version v2.0.0 to main.

The issue affects this repository, which deppends on this other one. To discover this issue, we created this pull request.

The "parent" project can compile with no issues, but the "child" one errors out with this error:

Run threeal/cmake-action@main
-- Building for: Visual Studio 17 2022
-- The C compiler identification is MSVC [19](https://github.com/gigabit-clowns/xmipp4-communication-mpi/actions/runs/11990281683/job/33427612733#step:5:20).42.34433.0
-- The CXX compiler identification is MSVC 19.42.34433.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/[20](https://github.com/gigabit-clowns/xmipp4-communication-mpi/actions/runs/11990281683/job/33427612733#step:5:21)22/Enterprise/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/20[22](https://github.com/gigabit-clowns/xmipp4-communication-mpi/actions/runs/11990281683/job/33427612733#step:5:23)/Enterprise/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:41 (find_package):
  By not providing "Findxmipp4-core.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "xmipp4-core", but CMake did not find one.

  Could not find a package configuration file provided by "xmipp4-core" with
  any of the following names:

    xmipp4-coreConfig.cmake
    xmipp4-core-config.cmake

  Add the installation prefix of "xmipp4-core" to CMAKE_PREFIX_PATH or set
  "xmipp4-core_DIR" to a directory containing one of the above files.  If
  "xmipp4-core" provides a separate development package or SDK, be sure it
  has been installed.

-- Configuring incomplete, errors occurred!

As stated before, this error only occurs selecting cmake-action in branch main, but works fine in v2.0.0. Is there anything that gets set differently in the tags when they get generated for release that makes it necessary to use a tag always, or could it be a bug introduced post 2.0.0?

threeal commented 4 days ago

Thanks for pointing this out. It is likely an error introduced in the main branch. It seems that the main version incorrectly sets the arguments used to call the CMake command, particularly for the input xmipp4-core_ROOT=D:\a\xmipp4-communication-mpi\xmipp4-communication-mpi/../xmipp4-core/dist.

I suggest trying to run the action again using the main branch. I just updated it yesterday to include logs for the executed command (see #524). Check what makes the command from the main branch differ from the one in the v2.0.0 tag.

MartinSalinas98 commented 4 days ago

Okay, so I have just made a test in this draft Pull Request.

At first, I set both uses of cmake action (one in the main workflow and another in a composite action) to use main branch, and the results were:

-- Configuring incomplete, errors occurred! Error: Command exited with status code 1

Then, I reverted the version in the main workflow to `v2`, keeping the one in the composite to `main`.
The installation of the dependency still worked the same, and the main project compilation-installation worked too:

Run threeal/cmake-action@v2 "C:\Program Files\CMake\bin\cmake.exe" D:\a\xmipp4-communication-mpi\xmipp4-communication-mpi -B D:\a\xmipp4-communication-mpi\xmipp4-communication-mpi/build -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release -Dxmipp4-core_ROOT=D:\a\xmipp4-communication-mpi\xmipp4-communication-mpi/../xmipp4-core/dist -- Building for: Visual Studio 17 2022 -- The C compiler identification is MSVC 19.42.34433.0 -- The CXX compiler identification is MSVC 19.42.34433.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - not found -- Found Threads: TRUE -- Found MPI_CXX: C:/Program Files (x86)/Intel/oneAPI/mpi/latest/lib/impi.lib (found suitable version "3.1", minimum required is "3") -- Found MPI: TRUE (found suitable version "3.1", minimum required is "3") found components: CXX -- Configuring done (15.3s) -- Generating done (0.1s) CMake Warning: Manually-specified variables were not used by the project: CMAKE_BUILD_TYPE -- Build files have been written to: D:/a/xmipp4-communication-mpi/xmipp4-communication-mpi/build "C:\Program Files\CMake\bin\cmake.exe" --build D:\a\xmipp4-communication-mpi\xmipp4-communication-mpi/build --config Release MSBuild version 17.12.6+db5f6012c for .NET Framework 1>Checking Build System Building Custom Rule D:/a/xmipp4-communication-mpi/xmipp4-communication-mpi/CMakeLists.txt mpi_communicator.cpp mpi_communicator_backend.cpp mpi_error.cpp mpi_instance.cpp mpi_operation.cpp ...



Indeed, it looks like in `main` branch, flag `xmipp4-core_ROOT` is not being parsed correctly, missing the `\` characters, which explains why this issue is only happening in our Windows build. 

**Note**: it also uses cmake from the PATH instead of specifying the full path to it, but that does not seem to be causing any issues, and I'll leave it up to you to choose which one of the two behaviours (absolte path vs PATH variable) is the preferred one. 
threeal commented 3 days ago

Right, the issue seems to be caused by the action incorrectly parsing the command-line arguments. I'll probably need to write my own function for handling arguments with quotes instead of relying on an external library.

threeal commented 3 days ago

@MartinSalinas98 try this branch: add-parse-args-quote-func

MartinSalinas98 commented 3 days ago

Seems to work fine:

Run threeal/cmake-action@add-parse-args-quote-func
cmake D:\a\xmipp4-communication-mpi\xmipp4-communication-mpi -B D:\a\xmipp4-communication-mpi\xmipp4-communication-mpi/build -DCMAKE_C_COMPILER=cl -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release -Dxmipp4-core_ROOT=D:\a\xmipp4-communication-mpi\xmipp4-communication-mpi/../xmipp4-core/dist
-- Building for: Visual Studio 17 2022
-- The C compiler identification is MSVC [19](https://github.com/gigabit-clowns/xmipp4-communication-mpi/actions/runs/12026247847/job/33524847368?pr=17#step:5:20).42.34433.0
-- The CXX compiler identification is MSVC 19.42.34433.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/[20](https://github.com/gigabit-clowns/xmipp4-communication-mpi/actions/runs/12026247847/job/33524847368?pr=17#step:5:21)22/Enterprise/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/20[22](https://github.com/gigabit-clowns/xmipp4-communication-mpi/actions/runs/12026247847/job/33524847368?pr=17#step:5:23)/Enterprise/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Found half: D:/a/xmipp4-communication-mpi/xmipp4-core/dist/include (found version "2.2.0")
-- Found MPI_CXX: C:/Program Files (x86)/Intel/oneAPI/mpi/latest/lib/impi.lib (found suitable version "3.1", minimum required is "3")
-- Found MPI: TRUE (found suitable version "3.1", minimum required is "3") found components: CXX
-- Configuring done (13.0s)
CMake Warning:
-- Generating done (0.1s)