New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake Tools 1.4.0 doesn't define CMAKE_BUILD_TYPE in a project's build directory's CMakeCache.txt #1298
Comments
If you manually set the preferred generator to be "Ninja", then CMAKE_BUILD_TYPE is defined in the CMakeCache.txt file. If no preferred generator is specified, Visual Studio is used as the generator and it doesn't specify CMAKE_BUILD_TYPE in the CMakeCache.txt file. Given that Visual Studio may be the default for a lot of people, it'd be good if it, by default, added CMAKE_BUILD_TYPE to CMakeCache.txt. I'm not sure if it's a bug, a problem with my installation, or something I should do (but didn't know to do). Perhaps if someone can comment, then we can be sure which of these it is. |
Hi! I think I suggest to add the following lines to
With this in the
|
Looks like the problem is the CMake generator: for older CMake Tools it was I also need |
Quite the opposite: |
So are you saying you can't get the extension to pick Ninja again? Did you set the |
Well, I cannot reproduce the issue anymore - after upgrade to 1.4.1 and some cleanups |
VS Code has added a setting for Cmake which sets the build type on multi config generators (the default generator.) if you open File > Preferences > Settings and search "CMAKE_" or "CMAKE_BUILD_TYPE" it'll be the first option to appear. It'd be nice if this were the default, but well I'm not sure where we'd bug them about it... and well I can't be bothered to do that. |
We'll evaluate changing the default value of this setting in the 1.16 extension release. |
Brief Issue Summary
I am using Visual Studio Code and CMake Tools to build a simple C++ project using OpenCV. The project relies on OpenCV's opencv_world430d.dll and OpenCV_world.dll files. To copy them to the build and install directory, I use an if statement to check whether the CMAKE_BUILD_TYPE matches either Debug or Release; then I define a variable equal to the path to the corresponding debug or release dll. Lastly, I use a custom command to copy the files to the build directory and install them to a desired install location. The problem is, CMAKE_BUILD_TYPE is not defined - even though I've configured the project and selected a Debug configuration.
Expected:
If build type is Debug, the syntax if(${CMAKE_BUILD_TYPE) MATCHES Debug) should return true; else, if build type is Release, the syntax if(${CMAKE_BUILD_TYPE) MATCHES Release) should return true.
It is expected that CMAKE_BUILD_TYPE is defined as either Debug or Release.
Apparent Behavior
CMAKE_BUILD_TYPE is not defined.
Platform and Versions
Other Notes/Information
Looking in the project's build directory's CMakeCache.txt file, CMAKE_BUILD_TYPE is not included. When I use Visual Studio 2019, the project behaves as expected and CMAKE_BUILD_TYPE is included in the CMakeCache.txt file.
The text was updated successfully, but these errors were encountered: