lukka / run-cmake

GitHub Action to build C++ applications with CMake (CMakePresets.json), Ninja and vcpkg on GitHub.
MIT License
176 stars 19 forks source link

CMAKE not recognizing BuildType argument #4

Closed rickomax closed 4 years ago

rickomax commented 4 years ago

Hi!

I'm passing -DCMAKE_BUILD_TYPE=Release argument to the cmakeAppendedArgs action, but CMAKE doesn't recognize it. Is there any extra step needed to make it work?

lukka commented 4 years ago

@rickomax thanks for the report! I think that the problem is the following:

 cmakeAppendedArgs:
    default: ""
    required: false
    description: "Provides a mean to provide all the CMake arguments. 
This is required when using CMakeLists.txt in Advanced mode. 
For CMakeSettings.json, the arguments are already inferred, but you can append
 your arguments providing them here.  Used by CMakeListsTxtAdvanced and CMakeSettingsJson modes."

I think the action should be improved and warn about any argument that is being currently set by the user but disregarded at the same time during execution.

imbillow commented 4 years ago

I have the same problem, by using cmakeBuildType: Release and cmakeGenerator: VS16Win64

CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_BUILD_TYPE
imbillow commented 4 years ago

I see this

In the build pass, it also need passing a args --config Release with Visual Studio or Xcode.

lukka commented 4 years ago

@iovw thanks for the report! The problem is that run-cmake action is passing CMAKE_BUILD_TYPE when it is not necessary (for example, when the Visual Studio generator is being used), and CMake is then correctly reporting the warning about 'unused input'.

In order to not show the warning, you could either use CMake's Ninja generator. Also take in consideration that with using cmakeListsOrSettingsJson : CMakeListsTxtAdvanced you can create your command line for CMake using cmakeAppendedArgs

I believe the original poster has a slightly different problem, we will find out.

rickomax commented 4 years ago

This is my full command, which still doesn't work:

steps:
      - uses: actions/checkout@v2
      - uses: lukka/run-cmake@v0
        with:
          cmakeListsOrSettingsJson: CMakeListsTxtAdvanced
          cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt'
          useVcpkgToolchainFile: false
          buildDirectory: '${{ runner.workspace }}/build/win64'
          cmakeAppendedArgs: '-G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=MinSizeRel -DASSIMP_BUILD_TESTS=OFF -DASSIMP_BUILD_ASSIMP_TOOLS=OFF -DASSIMP_NO_EXPORT=ON -DBUILD_SHARED_LIBS=ON -DUSE_AES=OFF -DZIP_64=ON -DSKIP_INSTALL_ALL=ON -DASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT=ON -DSKIP_MSVC_UPDATE=ON'      
rickomax commented 4 years ago

The --config containing the build type part must be called on the cmake --build command which I'm not sure the location. Edit: I guess I found, testing.

rickomax commented 4 years ago

It worked! I had to put it here:

buildWithCMakeArgs: '--config MinSizeRel' 
lukka commented 4 years ago

If you feel like the addition of --config argument should happen automatically, let me know, i am always open to improvements. I have not put efforts around this because i would strongly suggest to use Ninja: in this case there is no need to specify the config at build time (as it is a single configuration CMake's generator).

imbillow commented 4 years ago

Yeah, I think it should passing the --config argument automatically, when using Visual Studio generator and specific a cmakeBuildType.

lukka commented 4 years ago

@iovw @rickomax should be fixed now (i.e. for multi config generator the proper '--config' is passed at build time, and not CMAKE_BUILD_TYPE passed during configuration).

imbillow commented 4 years ago

That's great.

rickomax commented 4 years ago

Ty!