Hi,<div><br></div><div>Try putting set(CMAKE_USER_MAKE_RULES_OVERRIDE MyCompilerFlags) before project() command.</div><div>Then, override variable CMAKE_BUILD_TYPE_INIT (with plain unconditional set command, without putting into cache) in MyCompilerFlags.cmake file (make sure you put it into location CMake can reach).</div>
<div><br></div><div>Regards,</div><div>Yuri</div><div><br><div class="gmail_quote">2011/3/7 Gabriel Petrovay <span dir="ltr"><<a href="mailto:gabipetrovay@gmail.com">gabipetrovay@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
This does not work because the "NMake Makefile" generator already sets<br>
the variable: CMAKE_BUILD_TYPE to "Debug"<br>
<br>
So your code will never be executed:<br>
if(NOT CMAKE_BUILD_TYPE)<br>
# it will never get here<br>
set(CMAKE_BUILD_TYPE RelWithDebInfo)<br>
endif(NOT CMAKE_BUILD_TYPE)<br>
<br>
And I want to have a default of "Release".<br>
<br>
<br>
Gabriel<br>
<br>
On Mon, Mar 7, 2011 at 3:14 AM, 徐亮 <<a href="mailto:lxu4net@gmail.com">lxu4net@gmail.com</a>> wrote:<br>
> You can check if the variable has defined. You can see<br>
> "<a href="http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:if" target="_blank">http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:if</a>" for<br>
> detail information.<br>
><br>
> if(NOT CMAKE_BUILD_TYPE)<br>
> set(CMAKE_BUILD_TYPE RelWithDebInfo)<br>
> endif()<br>
><br>
> 2011/3/7 Gabriel Petrovay <<a href="mailto:gabipetrovay@gmail.com">gabipetrovay@gmail.com</a>><br>
<div><div></div><div class="h5">>><br>
>> Hi,<br>
>><br>
>> I don't understand how to do that...<br>
>><br>
>> The user who builds does not set any environment and does not provide<br>
>> any -D arguments. I want CMake to automatically configure variables<br>
>> like: CMAKE_BUILD_TYPE or CMAKE_INSTALL_PREFIX when the user does not<br>
>> provide them. So I want *my* default values. But I don't want to set<br>
>> them when the user provides the *generator* ("NMake Makefiles")<br>
>> default values.<br>
>><br>
>> The only way I see it is for CMake to tell you what parameters were<br>
>> there in the command line. Does CMake support this?<br>
>><br>
>> How do you do this with the PATH environment variable?<br>
>><br>
>><br>
>> Gabriel<br>
>><br>
>> On Mon, Mar 7, 2011 at 2:41 AM, 徐亮 <<a href="mailto:lxu4net@gmail.com">lxu4net@gmail.com</a>> wrote:<br>
>> >> From: Gabriel Petrovay <<a href="mailto:gabipetrovay@gmail.com">gabipetrovay@gmail.com</a>><br>
>> >> Subject: [CMake] CMake command line arguments<br>
>> >><br>
>> >> Hi,<br>
>> >><br>
>> >> Is there a way to read the arguments that were passed to CMake from<br>
>> >> inside a CMakeLists.txt file?<br>
>> >><br>
>> >> There is a problem that some generators (like "NMake Makefiles") set a<br>
>> >> default value for certain variables (like CMAKE_BUILD_TYPE=Debug,<br>
>> >> CMAKE_INSTALL_PREFIX=C:\Program Files\${CMAKE_PROJECT_NAME})<br>
>> >><br>
>> >> >From inside CMake one can not set up a different default value if the<br>
>> >> user does not specify it with a -D option. This is because<br>
>> >> IF(CMAKE_BUILD_TYPE) will always be true because of the default set by<br>
>> >> the generator ("NMake Makefiles").<br>
>> >><br>
>> >> There was this guy having the same problem:<br>
>> >> <a href="http://www.mail-archive.com/cmake@cmake.org/msg09640.html" target="_blank">http://www.mail-archive.com/cmake@cmake.org/msg09640.html</a><br>
>> >><br>
>> >> Any solution how one can solve this? Reading the arguments passed to<br>
>> >> CMake would be one, but I find no documentation/example/google_result<br>
>> >> for this.<br>
>> >><br>
>> >><br>
>> >> Thanks!<br>
>> >><br>
>> >> --<br>
>> >> MSc Gabriel Petrovay<br>
>> >> Mobile: +41(0)787978034<br>
>> >> <a href="http://www.28msec.com" target="_blank">www.28msec.com</a><br>
>> >><br>
>> ><br>
>> > I use "environment variables" to handle this problem. Such as "$ENV{PATH}".<br>
>> > Liang Xu<br>
>> ><br>
>> > _______________________________________________<br>
>> > Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>> ><br>
>> > Visit other Kitware open-source projects at<br>
>> > <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>> ><br>
>> > Please keep messages on-topic and check the CMake FAQ at:<br>
>> > <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
>> ><br>
>> > Follow this link to subscribe/unsubscribe:<br>
>> > <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
>> ><br>
>><br>
>><br>
>><br>
>> --<br>
>> MSc Gabriel Petrovay<br>
>> Mobile: +41(0)787978034<br>
>> <a href="http://www.28msec.com" target="_blank">www.28msec.com</a><br>
><br>
><br>
><br>
</div></div>> --<br>
> Liang Xu<br>
<div><div></div><div class="h5">><br>
<br>
<br>
<br>
--<br>
MSc Gabriel Petrovay<br>
Mobile: +41(0)787978034<br>
<a href="http://www.28msec.com" target="_blank">www.28msec.com</a><br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a></div></div></blockquote></div><br></div>