Add cmake build script
This commit is contained in:
parent
93ddaed71c
commit
7f76079f80
55
CMakeLists.txt
Normal file
55
CMakeLists.txt
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.6)
|
||||||
|
include(CheckIncludeFiles)
|
||||||
|
|
||||||
|
project(foug_dataex C)
|
||||||
|
|
||||||
|
# Allow the user to build a static library
|
||||||
|
option(BUILD_SHARED_LIBS "Build shared libraries (DLL)" ON)
|
||||||
|
|
||||||
|
# Declare fougstl-c library
|
||||||
|
file(GLOB_RECURSE ALL_SRC_FILES src/c/*)
|
||||||
|
add_library(fougstl-c ${ALL_SRC_FILES})
|
||||||
|
|
||||||
|
# Have <stdint.h> ?
|
||||||
|
check_include_files(stdint.h HAVE_STDINT_H)
|
||||||
|
configure_file(src/c/config.h.cmake config.h @ONLY)
|
||||||
|
include_directories(${CMAKE_BINARY_DIR}) # For generated "config.h"
|
||||||
|
|
||||||
|
# Specific flags for gcc
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ansi -pedantic-errors")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra -fstrict-aliasing -Wstrict-aliasing -Wcast-align -Wlogical-op -Wfloat-equal")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Specific flags for Visual C++
|
||||||
|
if(MSVC)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -TC")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
|
add_definitions(-DFOUG_LIB_DLL
|
||||||
|
-DFOUG_LIB_MAKE_DLL
|
||||||
|
-DFOUG_DATAEX_LIBSTL_DLL
|
||||||
|
-DFOUG_DATAEX_LIBSTL_MAKE_DLL)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Declare installs
|
||||||
|
install(FILES ${CMAKE_BINARY_DIR}/config.h DESTINATION include/dataex/c)
|
||||||
|
|
||||||
|
file(GLOB C_GLOBAL_HEADERS src/c/*.h)
|
||||||
|
install(FILES ${C_GLOBAL_HEADERS} DESTINATION include/dataex/c)
|
||||||
|
|
||||||
|
file(GLOB C_LIBSTL_HEADERS src/c/libstl/*.h)
|
||||||
|
install(FILES ${C_LIBSTL_HEADERS} DESTINATION include/dataex/c/libstl)
|
||||||
|
|
||||||
|
install(TARGETS fougstl-c
|
||||||
|
RUNTIME DESTINATION lib
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Examples:
|
||||||
|
# cmake ../.. -DCMAKE_INSTALL_PREFIX=../../gcc-linux64 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_DEBUG_POSTFIX=.debug
|
||||||
|
# cmake ../.. -DCMAKE_INSTALL_PREFIX=../../gcc-linux64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_RELEASE_POSTFIX=.release
|
||||||
|
# make VERBOSE=1 or cmake -DCMAKE_VERBOSE_MAKEFILE=TRUE
|
10
src/c/config.h.cmake
Normal file
10
src/c/config.h.cmake
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/* Generated by CMake */
|
||||||
|
|
||||||
|
#ifndef FOUG_CONFIG_H_CMAKE
|
||||||
|
#define FOUG_CONFIG_H_CMAKE
|
||||||
|
|
||||||
|
#ifndef HAVE_STDINT_H
|
||||||
|
#cmakedefine HAVE_STDINT_H
|
||||||
|
#endif /* HAVE_STDINT_H */
|
||||||
|
|
||||||
|
#endif /* FOUG_CONFIG_H_CMAKE */
|
@ -20,7 +20,9 @@
|
|||||||
# define FOUG_LIB_EXPORT
|
# define FOUG_LIB_EXPORT
|
||||||
#endif /* FOUG_LIB_DLL */
|
#endif /* FOUG_LIB_DLL */
|
||||||
|
|
||||||
#ifdef FOUG_USE_STDINT_H
|
#include "config.h" /* Generated by build system */
|
||||||
|
|
||||||
|
#ifdef HAVE_STDINT_H
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
#else
|
#else
|
||||||
typedef char int8_t;
|
typedef char int8_t;
|
||||||
|
Loading…
Reference in New Issue
Block a user