GLib_bcb test added
This commit is contained in:
parent
12f49ce0e9
commit
64a261d400
10
c/GLib_bcb/CMakeLists.txt
Normal file
10
c/GLib_bcb/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
project (GLibBCB)
|
||||
|
||||
cmake_minimum_required (VERSION 2.6)
|
||||
|
||||
set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||
|
||||
include_directories ("${PROJECT_SOURCE_DIR}/mylib")
|
||||
|
||||
add_subdirectory (mylib)
|
||||
add_subdirectory (test_gcc)
|
17
c/GLib_bcb/cmake/Toolchain-mingw32.cmake
Normal file
17
c/GLib_bcb/cmake/Toolchain-mingw32.cmake
Normal file
@ -0,0 +1,17 @@
|
||||
# the name of the target operating system
|
||||
SET(CMAKE_SYSTEM_NAME Windows)
|
||||
|
||||
# which compilers to use for C and C++
|
||||
SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
|
||||
SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
|
||||
SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
|
||||
|
||||
# here is the target environment located
|
||||
SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32 /home/kolan/build/mingw-install )
|
||||
|
||||
# adjust the default behaviour of the FIND_XXX() commands:
|
||||
# search headers and libraries in the target environment, search
|
||||
# programs in the host environment
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
42
c/GLib_bcb/cmake/cmake_FindGlib.cmake
Normal file
42
c/GLib_bcb/cmake/cmake_FindGlib.cmake
Normal file
@ -0,0 +1,42 @@
|
||||
pkg_check_modules(GLIB_PKG glib-2.0)
|
||||
|
||||
if (GLIB_PKG_FOUND)
|
||||
find_path(GLIB_INCLUDE_DIR NAMES glib.h PATH_SUFFIXES glib-2.0
|
||||
PATHS
|
||||
${GLIB_PKG_INCLUDE_DIRS}
|
||||
/usr/include/glib-2.0
|
||||
/usr/include
|
||||
/usr/local/include
|
||||
)
|
||||
find_path(GLIB_CONFIG_INCLUDE_DIR NAMES glibconfig.h PATHS ${GLIB_PKG_LIBDIR} PATH_SUFFIXES glib-2.0/include)
|
||||
|
||||
find_library(GLIB_LIBRARIES NAMES glib-2.0
|
||||
PATHS
|
||||
${GLIB_PKG_LIBRARY_DIRS}
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
)
|
||||
|
||||
else (GLIB_PKG_FOUND)
|
||||
# Find Glib even if pkg-config is not working (eg. cross compiling to Windows)
|
||||
find_library(GLIB_LIBRARIES NAMES glib-2.0)
|
||||
string (REGEX REPLACE "/[^/]*$" "" GLIB_LIBRARIES_DIR ${GLIB_LIBRARIES})
|
||||
|
||||
find_path(GLIB_INCLUDE_DIR NAMES glib.h PATH_SUFFIXES glib-2.0)
|
||||
find_path(GLIB_CONFIG_INCLUDE_DIR NAMES glibconfig.h PATHS ${GLIB_LIBRARIES_DIR} PATH_SUFFIXES glib-2.0/include)
|
||||
|
||||
endif (GLIB_PKG_FOUND)
|
||||
|
||||
if (GLIB_INCLUDE_DIR AND GLIB_CONFIG_INCLUDE_DIR AND GLIB_LIBRARIES)
|
||||
set(GLIB_INCLUDE_DIRS ${GLIB_INCLUDE_DIR} ${GLIB_CONFIG_INCLUDE_DIR})
|
||||
endif (GLIB_INCLUDE_DIR AND GLIB_CONFIG_INCLUDE_DIR AND GLIB_LIBRARIES)
|
||||
|
||||
if(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES)
|
||||
set(GLIB_FOUND TRUE CACHE INTERNAL "glib-2.0 found")
|
||||
message(STATUS "Found glib-2.0: ${GLIB_INCLUDE_DIR}, ${GLIB_LIBRARIES}")
|
||||
else(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES)
|
||||
set(GLIB_FOUND FALSE CACHE INTERNAL "glib-2.0 found")
|
||||
message(STATUS "glib-2.0 not found.")
|
||||
endif(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES)
|
||||
|
||||
mark_as_advanced(GLIB_INCLUDE_DIR GLIB_CONFIG_INCLUDE_DIR GLIB_INCLUDE_DIRS GLIB_LIBRARIES)
|
8
c/GLib_bcb/mylib/CMakeLists.txt
Normal file
8
c/GLib_bcb/mylib/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
||||
include (FindPkgConfig)
|
||||
include (cmake_FindGlib)
|
||||
|
||||
include_directories (${GLIB_INCLUDE_DIR})
|
||||
include_directories (${GLIB_PKG_INCLUDE_DIRS})
|
||||
|
||||
add_library (mylib SHARED mylib.c)
|
||||
target_link_libraries (mylib ${GLIB_LIBRARIES})
|
7
c/GLib_bcb/mylib/mylib.c
Normal file
7
c/GLib_bcb/mylib/mylib.c
Normal file
@ -0,0 +1,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void
|
||||
mylib_func (void)
|
||||
{
|
||||
puts ("Hello mylib_func ()! ;-)\n");
|
||||
}
|
2
c/GLib_bcb/mylib/mylib.h
Normal file
2
c/GLib_bcb/mylib/mylib.h
Normal file
@ -0,0 +1,2 @@
|
||||
void
|
||||
mylib_func (void);
|
8
c/GLib_bcb/test_gcc/CMakeLists.txt
Normal file
8
c/GLib_bcb/test_gcc/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
||||
include (FindPkgConfig)
|
||||
include (cmake_FindGlib)
|
||||
|
||||
include_directories (${GLIB_INCLUDE_DIR})
|
||||
include_directories (${GLIB_PKG_INCLUDE_DIRS})
|
||||
|
||||
add_executable (test_gcc test_gcc.c)
|
||||
target_link_libraries (test_gcc mylib ${GLIB_LIBRARIES})
|
8
c/GLib_bcb/test_gcc/test_gcc.c
Normal file
8
c/GLib_bcb/test_gcc/test_gcc.c
Normal file
@ -0,0 +1,8 @@
|
||||
#include "mylib.h"
|
||||
|
||||
int main (void)
|
||||
{
|
||||
mylib_func ();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user