juanmanzanero / fastest-lap

Fastest-lap is a vehicle dynamics simulator. It can be used to understand vehicle dynamics, to learn about driving techniques, to design car prototypes, or just for fun!
MIT License
575 stars 43 forks source link

Argument CMAKE_BUILD_TYPE optional during cmake build #13

Closed kktse closed 2 years ago

kktse commented 2 years ago

Background

Build option CMAKE_BUILD_TYPE is 'mandatory' because STREQUAL expects an argument. Force the expression to evaluate early by checking the existence of CMAKE_BUILD_TYPE. This makes CMAKE_BUILD_TYPE an optional build argument. Defaults to Release. Fixes build errors when using Docker build script, where at this time, cmake build flags can not be passed into the script.

Tested

$ cmake --version
cmake version 3.23.2

Without changes

        Configure Fastest-lap                                                                                                                                
        =====================                                                                                                                                

CMake Error at CMakeLists.txt:75 (if):                                                                                                                       
  if given arguments:                                                                                                                                        

    "MSYS" "AND" "STREQUAL" "Debug"                                                                                                                          

  Unknown arguments specified      

With changes prevents this error.

Checklist

Before submitting a pull request, make sure you satisfy all of the following points:

juanmanzanero commented 2 years ago

Hello Kelvin. Good, there's another instance of that same bit in src/main/c/CMakeLists.txt. Do you want to update it too? Cheers

juanmanzanero commented 2 years ago

Thank you Kelvin

juanmanzanero commented 2 years ago

Huh, for some reason this edit did not work as expected. The purpose of these lines are to skip the compilation of libfastestlapc when MSYS and Debug mode are used, because of some gnarly linker errors I honestly do not want to lose time in investigate.