[CMake] Three newbie questions: default build type, find_package-modules, default compiler flags

Michael Roth mroth at nessie.de
Sat Jan 16 14:04:57 EST 2010


Hello,

I'm a cmake newbie and have three questions:

a.) What is the best way to set a default build type? Currently I
    do something like this:

	if (NOT CMAKE_BUILD_TYPE)
		message(STATUS "No build type selected, default to Release")
		set(CMAKE_BUILD_TYPE "Release")
	endif()


b.) When writing find_package-modules, what are the standard variable
    names? Plural or singular?

	FOOBAR_INCLUDE_DIR
	FOOBAR_LIBRARY
	
	or

	FOOBAR_INCLUDE_DIRS
	FOOBAR_LIBRARIES

    Some docs and specific modules are inconsistent with one another.


c.) I have written:

	if (CMAKE_COMPILER_IS_GNUCC)
		message(STATUS "Gnu-Compiler detected, setting custom flags")
		set(CMAKE_C_FLAGS_DEBUG "-O2 -Wall -g")
		set(CMAKE_C_FLAGS_RELEASE "-O2 -Wall -fomit-frame-pointer -DNDEBUG")
		set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g")
	endif()


    But when I add flags to CMAKE_C_FLAGS they are prepended to the other
    three variants. Is this intended? Why?


Thank you for answering my questions.

--
Michael Roth


More information about the CMake mailing list