How force cmake debug/release

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How force cmake debug/release

Andy
In cmake I have:
if (${CMAKE_BUILD_TYPE} STREQUAL Release)
  message(WARNING "Release")
endif()

if (${CMAKE_BUILD_TYPE} STREQUAL Debug)
  message(WARNING "Debug")
endif()

(how write something like elseif?)

If I call "cmake ." it write: "Warning:Debug"
Debug is default and I must call "cmake . -DCMAKE_BUILD_TYPE=Release"
for release?

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How force cmake debug/release

Marc CHEVRIER
Have a look at the documentation :

https://cmake.org/cmake/help/v3.13/

Le 6 déc. 2018 à 09:51 +0100, Andy <[hidden email]>, a écrit :
In cmake I have:
if (${CMAKE_BUILD_TYPE} STREQUAL Release)
  message(WARNING "Release")
endif()

if (${CMAKE_BUILD_TYPE} STREQUAL Debug)
  message(WARNING "Debug")
endif()

(how write something like elseif?)

If I call "cmake ." it write: "Warning:Debug"
Debug is default and I must call "cmake . -DCMAKE_BUILD_TYPE=Release"
for release?
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: How force cmake debug/release

Simon Richter
In reply to this post by Andy
Hi,

On 06.12.18 09:50, Andy wrote:

> If I call "cmake ." it write: "Warning:Debug"
> Debug is default and I must call "cmake . -DCMAKE_BUILD_TYPE=Release"
> for release?

That depends on the generator used. Some generators require the build
type at configuration time, some at build time. For example, the Visual
Studio generator should generate files containing both Debug and Release
configurations, and neither of your code blocks should be run.

Ideally, you should never do anything directly that depends on the build
type, but only prepare things. So rather than

if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif()

you'd use

set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")

so generators that handle multiple build types at the same time can work.

   Simon


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

signature.asc (499 bytes) Download Attachment