Re: Using CMake
- From: Maik Beckmann <maikbeckmann gmx de>
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: Using CMake
- Date: Mon, 14 Aug 2006 11:43:57 +0200
Hello
I'm using the autotools on linux and cmake on winxp (at work). The
UsePkgConfig macro seems to be a "gcc only" hack. Here is an additional
macro which uses UsePkgConfig, but returns the compiler independent
information cmake needs.(I didn't tried anything else than mingw until
now, please give response.)
greetz Maik
*** the macro... cmake-version =>2.4:
## FILE...
include(UsePkgConfig)
MACRO(PKGCONFIG_PARSE_FLAGS FLAGS INCLUDES DEFINES)
#MESSAGE("DEBUG: FLAGS: ${FLAGS}")
STRING(REGEX MATCHALL "-I[^ ]*" ${INCLUDES} "${FLAGS}")
STRING(REGEX REPLACE "-I" "" ${INCLUDES} "${${INCLUDES}}")
#MESSAGE("DEBUG: INCLUDES: ${${INCLUDES}}")
STRING(REGEX REPLACE "-I[^ ]*" "" ${DEFINES} "${FLAGS}")
#MESSAGE("DEBUG: DEFINES: ${${DEFINES}}")
ENDMACRO(PKGCONFIG_PARSE_FLAGS)
########################################
MACRO(PKGCONFIG_PARSE_LIBS LIBS LINKDIRS LINKLIBS)
#MESSAGE("DEBUG: LIBS: ${LIBS}")
STRING(REGEX MATCHALL "-L[^ ]*" ${LINKDIRS} "${LIBS}")
STRING(REGEX REPLACE "-L" "" ${LINKDIRS} "${${LINKDIRS}}")
#MESSAGE("DEBUG: LINKDIRS: ${${LINKDIRS}}")
STRING(REGEX MATCHALL "-l[^ ]*" ${LINKLIBS} "${LIBS}")
STRING(REGEX REPLACE "-l" "" ${LINKLIBS} "${${LINKLIBS}}")
#MESSAGE("DEBUG: LINKLIBS: ${${LINKLIBS}}")
ENDMACRO(PKGCONFIG_PARSE_LIBS)
########################################
MACRO(PKGCONFIG_PARSE LIB ICDS LDIRS LIBS DEFS)
PKGCONFIG("${LIB}" INCLUDE_DIRS LIB_DIRS LIBFLAGS CFLAGS)
PKGCONFIG_PARSE_FLAGS( "${CFLAGS}" ${ICDS} ${DEFS})
PKGCONFIG_PARSE_LIBS( "${LIBFLAGS}" ${LDIRS} ${LIBS} )
ENDMACRO(PKGCONFIG_PARSE)
## ... EOF
* I saved it to /home/maik/cmake/PkgConfigParser.cmake
*** usage for a 'main.cc' in folder 'src'
** CMakeLists.txt :
## FILE...
project(tests)
include(/home/maik/cmake/PkgConfigParser.cmake)
pkgconfig_parse(gtkmm-2.4 gtkmm_inc gtkmm_ldirs gtkmm_libs gtkmm_def)
include_directories( ${gtkmm_inc} )
link_directories( ${gtkmm_ldirs} )
add_executable(test1 src/main.cc)
target_link_libraries(test1 ${gtkmm_libs})
## ... EOF
** main.cc:
// FILE ...
#include<gtkmm.h>
int main(int argc, char** argv) {
Gtk::Main kit(argc,argv);
Gtk::Window win;
win.show();
Gtk::Main::run(win);
return 0;
}
// ... EOF
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]