tags:

views:

94

answers:

1

This is the FindGTK.cmake:

# don't even bother under WIN32
IF(UNIX)


...


ENDIF(UNIX)

So it's not intended to work in windows at all,even though I've already installed the gtk+-bundle_2.20.0-20100406_win32 days ago.

How should I properly use gtk with cmake now?

A: 

Given that you are using GTK 2.20.0 (i.e. version is >= 2), you should be using GTK2 instead of GTK. But, if FindGTK2 has the same problem, then you can use find_path to locate the header files, and you can use find_library to locate the associated library files. Putting those together, you can construct the symbols GTK2_FOUND, GTK2_LIBRARIES, and GTK2_INCLUDE_DIRS that it should produce. You may find my FindUnitTestPlusPlus.cmake file a little bit helpful; it makes use of "FindPackageHandleStandardArgs", which takes care of the nitty gritty details of making sure to fail if the library isn't there and the REQUIRED flag is given. Unfortunately, there really isn't much documentation out there on creating custom FindXYZ.cmake modules; however, you should be able to hack something together from the existing modules, I think.

Another option is to contact the maintainer of that particular module. A list of CMake find module maintainers may be found at the link. Philip Lowman is the go-to guy for the FindGTK2 module.

Michael Aaron Safyan
I decided to write a `FindGTK2.cmake` myself,but how can I overwrite the built-in one without deleting or replacing it with my own file?
Gtker
@Runner, you can set the variable CMAKE_MODULE_PATH to point to the folder in which your own FindGTK2.cmake file is located; CMake searches CMAKE_MODULE_PATH before the default folder.
Michael Aaron Safyan
@Michael Aaron Safyan,writing a `FindGTK2.cmake` is harder than I thought...How can I just manually include the header and library of gtk2 instead of writing a `FindGTK2.cmake`?
Gtker