[cmake] variable for first run

Sören Freudiger muffmolch at gmx.de
Fri Feb 10 02:36:42 EST 2006


Hi
I know this question was asked long time ago and I answered it already, but
maybe there is a new solution for the problem.

I wrote a macro that adds CXX compiler flags to my existing ones: 

MACRO(ADD_CXX_FLAGS)
  FOREACH(arg ${ARGN})
    SET(TMP ${arg}) #elsewise the Seperate command doesn't work)
    SEPARATE_ARGUMENTS(TMP)
    FOREACH(option ${TMP})
      STRING(REGEX REPLACE " ${option}" "" CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS}")
      STRING(REGEX REPLACE "${option}" "" CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS}")

      ######################### 
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${option}" CACHE STRING
"common C++ build flags" FORCE)
      #########################

    ENDFOREACH(option ${TMP})  
  ENDFOREACH(arg ${ARGN})
ENDMACRO(ADD_CXX_FLAGS)

works fine, but hte problem is that these options are forced every time I am
running cmake. But sometimes I want to remove some of these flags within the
ccmake application (not via CMakeLists.txt). But of course after "configure"
these options are set again.
Right now I am setting an variable "RUNNED_ONE_TIME" at the end of the
CMakeLists.txt file and have a IF-option around ADD_CXX_FLAGS. works to, but
is not the best way. so is there a CMAKE-variable that I can ask? or some
totaly other way to avoid the second force?

Kind regards,
Soeren

--
Dipl.-Ing. Soeren Freudiger
Institut fuer ComputerAnwendungen im Bauingenieurwesen TU Braunschweig, 
Pockelsstr. 3, D-38106 Braunschweig
Tel.: +49 531/391-7595,
Mobil: +49 176/210 17 444

email: freud at cab.bau.tu-bs.de
http://www.cab.bau.tu-bs.de/  



More information about the CMake mailing list