[CMake] setting CMAKE_MODULE_PATH removes the default path?

Pierre pierre.php at gmail.com
Thu Jan 11 15:46:15 EST 2007


On 1/11/07, Axel Roebel <Axel.Roebel at ircam.fr> wrote:
> On Thursday 11 January 2007 16:47, Pierre wrote:
> > Hello,
> >
> > Doing:
> >
> > SET(CMAKE_MODULE_PATH "${FOO_CMAKE_DIR}")
>
> Effectively this is correct, it worked for me like this
> on all cmake versions I ever tried. The default path
> should be searched for automagically.

Sounds logical and it is what I expect, very good :)

I remove my 2.4.3 install and use now the freshly released 2.4.6.

> You find the implementation in
> cmake-source-dir/Source/cmMakefile.cxx
> function GetModulesFiles.

The "out.txt" attachment is the ouput of the CMakeLists.txt.  I simply
added a printf in cmMakefile::GetModulesFile, in the true clause of
"if(cmSystemTools::FileExists(itempl.c_str()))".

I was wrong when I said that cmake did not find or do not use the
default path, it does.  But the macros is not defined. If I add
include(CheckIncludeFile), it works. I wonder what I broke (as it
seems to work for anyone else) as it is now a fresh install from the
official 2.4.6 sources package. Any idea?

As a workaround, I will a file to include all macros I need. It's ugly
but it will work.

> The default location is
> ${CMAKE_ROOT}/Modules.
> You may want to check whether
> your CMAKE_ROOT variable
> is correct...

It is set correctly.

--Pierre
-------------- next part --------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.3 FATAL_ERROR)
PROJECT(GD)

SET(GD_VERSION_MAJOR "2")
SET(GD_VERSION_MINOR "0")
SET(GD_VERSION_PATCH "34")
SET(GD_VERSION "${GD_VERSION_MAJOR}.${GD_VERSION_MINOR}.${GD_VERSION_PATCH}")

message(STATUS "module path: ${CMAKE_MODULE_PATH} ${CMAKE_ROOT}")

SET(CMAKE_MODULE_PATH "${GD_SOURCE_DIR}/CMakeModules")

message(STATUS "module path: ${CMAKE_MODULE_PATH} !!!")

include(CheckIncludeFiles)

FIND_PACKAGE(PNG REQUIRED)
FIND_PACKAGE(ZLIB)
FIND_PACKAGE(JPEG)
FIND_PACKAGE(PTHREAD)
FIND_PACKAGE(Freetype)
SET(HAVE_FT2BUILD_H 0)


if (FREETYPE_FOUND)
	INCLUDE_DIRECTORIES(${FREETYPE_INCLUDE_DIR})
	MESSAGE(STATUS "${CMAKE_MODULE_PATH}")
	CHECK_INCLUDE_FILE(ft2build.h HAVE_FT2BUILD_H)
	SET(HAVE_LIBFREETYPE 1)
ENDIF(FREETYPE_FOUND)

IF(ZLIB_FOUND)
	INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR})
	SET(HAVE_LIBZ 1)
	SET(HAVE_LIBPNG_PNG_H 1)
ENDIF(ZLIB_FOUND)

IF(PNG_FOUND)
	INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR})
	SET(HAVE_LIBPNG 1)
ENDIF(PNG_FOUND)

IF(JPEG_FOUND)
	INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR})
	SET(HAVE_LIBJPEG 1)
ENDIF(JPEG_FOUND)

SET (LIBGD_SRC_FILES
	gd.c
	gdfx.c
	gd_security.c
	gd_gd.c
	gd_gd2.c
	gd_io.c
	gd_io_dp.c
	gd_gif_in.c
	gd_gif_out.c
	gd_io_file.c
	gd_io_ss.c
	gd_jpeg.c
	gd_png.c
	gd_ss.c
	gd_topal.c
	gd_wbmp.c
	gdcache.c
	gdfontg.c
	gdfontl.c
	gdfontmb.c
	gdfonts.c
	gdfontt.c
	gdft.c
	gdhelpers.c
	gdhelpers.h
	gdkanji.c
	gdtables.c
	gdxpm.c
	jisx0208.h
	wbmp.c
	wbmp.h
)

Set(BUILD_SHARED_LIBS On)
INCLUDE_DIRECTORIES(BEFORE ${PROJET_SOURCE_DIR})
CONFIGURE_FILE(config.h.cmake test.h)

add_library (gd ${LIBGD_SRC_FILES})
target_link_libraries(gd ${FREETYPE_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARIES})
-------------- next part --------------
itempl: /usr/share/cmake-2.4/Modules/CMakeSystemSpecificInformation.cmake Found
itempl: /usr/share/cmake-2.4/Modules/CMakeGenericSystem.cmake Found
itempl: /usr/share/cmake-2.4/Modules/Platform/gcc.cmake Found
itempl: /usr/share/cmake-2.4/Modules/Platform/Linux.cmake Found
itempl: /usr/share/cmake-2.4/Modules/Platform/UnixPaths.cmake Found
itempl: /usr/share/cmake-2.4/Modules/CMakeCInformation.cmake Found
itempl: /usr/share/cmake-2.4/Modules/CMakeCommonLanguageInclude.cmake Found
itempl: /usr/share/cmake-2.4/Modules/CMakeCXXInformation.cmake Found
itempl: /usr/share/cmake-2.4/Modules/CMakeCommonLanguageInclude.cmake Found
-- module path:  /usr/share/cmake-2.4
-- module path: /home/pierre/projects/gd/gdcmake/CMakeModules !!!
itempl: /usr/share/cmake-2.4/Modules/CheckIncludeFiles.cmake Found
itempl: /home/pierre/projects/gd/gdcmake/CMakeModules/FindPNG.cmake Found
itempl: /usr/share/cmake-2.4/Modules/FindZLIB.cmake Found
-- Found PNG: /usr/lib/libpng.so
itempl: /usr/share/cmake-2.4/Modules/FindZLIB.cmake Found
itempl: /usr/share/cmake-2.4/Modules/FindJPEG.cmake Found
-- Found JPEG: /usr/lib/libjpeg.so
itempl: /home/pierre/projects/gd/gdcmake/CMakeModules/FindPTHREAD.cmake Found
itempl: /home/pierre/projects/gd/gdcmake/CMakeModules/FindFreetype.cmake Found
-- Version
-- Looking for freetype files...
-- Found Freetype: 2.2.1
-- /home/pierre/projects/gd/gdcmake/CMakeModules
CMake Error: Error in cmake code at
/home/pierre/projects/gd/gdcmake/CMakeLists.txt:28:
Unknown CMake command "CHECK_INCLUDE_FILE".
-- Configuring done


More information about the CMake mailing list