Repository: conan-io/conan

Issue:
[bug] cmake_find_package_multi generator should not enforce that certain buildtypes are used.
### Environment Details (include every applicable attribute)
  * Conan version: 1.26.1

### Steps to reproduce (Include if Applicable)

I'm using cmake-conan but i'd assume this is preproduceable with other means too. 

CMakeLists.txt has:
```cmake
  set(CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo")
  conan_cmake_run(
    CONANFILE ${ROOT_CONANFILE}
    BASIC_SETUP
    UPDATE
    CMAKE_TARGETS
    CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}"
    GENERATORS "cmake_find_package_multi"
```

### Logs (Executed commands with output) (Include/Attach if Applicable)

```
-- Conan: Loading conanbuildinfo_multi.cmake
CMake Error at build/conanbuildinfo_multi.cmake:3488 (message):
  No conanbuildinfo_release.cmake, please install the Release conf first
Call Stack (most recent call first):
  cmake/conan.cmake:464 (include)
  cmake/conan.cmake:507 (conan_load_buildinfo)
  CMakeLists.txt:27 (conan_cmake_run)
```

### Afterthoughts 

For me, it it feels like that FATAL_ERROR messages are not really necessary, conanbuildinfo_$buildtype.cmake files are generated based upon what user provides and if release or debug is not on that list, they shouldnt be enforced to be present. 

In my usecase, this would actually save a minute from initial cmake run on 1gb network and cache on fast m2 ssd.




Discussion:
Hi, @rasjani !

This happen for the `cmake_multi` generator, not for the `cmake_find_package_multi`. But, anyway, I see that the `cmake_multi` generator is added when using the `_multi` variant of the `cmake_find_package` one.

So yes, we should relax this requirement [here](https://github.com/conan-io/conan/blob/a04efb057946f530a5e3315fcb81fc1235d9d32f/conans/client/generators/cmake_common.py#L967), I'm not aware of any reason why we should raise for one generator and not the other... maybe there is a reason and CMake cache doesn't update values from those files if they are not included from the beginning.

Thanks for reporting
@jgsogo  It’s cmake_multi (my bad) and I forgot to add the link to the same source. Even the tile was incorrect, it should have said: should not.

I can submit a patch too. Easier way would be to just remove else branches with fatal_message.  Else branch could alternatively check if build type is in CMAKE_CONFIGURATION_TYPES and issue the fatal, if the build type is there but corresponding conanbuildinfo is missing to have a sort of sanity check?
I think that removing the fatal message could be enough, but adding the other information now that we remove the message can be useful and it is pretty straightforward (I want to believe no one is using that failure as a feature). An alternative is how we do the same in the `cmake_find_package_multi` ([here](https://github.com/conan-io/conan/blob/a04efb057946f530a5e3315fcb81fc1235d9d32f/conans/client/generators/cmake_find_package_multi.py#L31)).

We really need to check that if the user adds one of the configuration files after the first "cmake configure", CMake will realize about the new file in the next run. Probably it will, but just double check.

So yes, if you want to make the PR yourself... please, do.

Thanks!

Resolving patch:
diff --git a/conans/client/generators/cmake_common.py b/conans/client/generators/cmake_common.py
--- a/conans/client/generators/cmake_common.py
+++ b/conans/client/generators/cmake_common.py
@@ -966,25 +966,12 @@ def _conan_basic_setup_common(addtional_macros, cmake_multi=False):
 
 cmake_macros_multi = "\n".join([
     textwrap.dedent("""
-        if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/conanbuildinfo_release.cmake)
-            include(${CMAKE_CURRENT_LIST_DIR}/conanbuildinfo_release.cmake)
-        else()
-            message(FATAL_ERROR "No conanbuildinfo_release.cmake, please install the Release conf first")
-        endif()
-
-        if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/conanbuildinfo_debug.cmake)
-            include(${CMAKE_CURRENT_LIST_DIR}/conanbuildinfo_debug.cmake)
-        else()
-            message(FATAL_ERROR "No conanbuildinfo_debug.cmake, please install the Debug conf first")
-        endif()
-
-        if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/conanbuildinfo_minsizerel.cmake)
-            include(${CMAKE_CURRENT_LIST_DIR}/conanbuildinfo_minsizerel.cmake)
-        endif()
-
-        if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/conanbuildinfo_relwithdebinfo.cmake)
-            include(${CMAKE_CURRENT_LIST_DIR}/conanbuildinfo_relwithdebinfo.cmake)
-        endif()
+        ### load generated conanbuildinfo files.
+        foreach(_name release debug minsizerel relwithdebinfo)
+            if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/conanbuildinfo_${_name}.cmake)
+                include(${CMAKE_CURRENT_LIST_DIR}/conanbuildinfo_${_name}.cmake)
+            endif()
+        endforeach()
         """),
     CMakeCommonMacros.conan_set_vs_runtime_preserve_build_type,
     CMakeCommonMacros.conan_set_find_paths_multi,


Test patch: