diff options
Diffstat (limited to 'cmake')
| -rw-r--r-- | cmake/Toolchain-Arch-mingw32.cmake.sample | 30 | ||||
| -rw-r--r-- | cmake/Toolchain-OSX-mingw32.cmake.sample | 32 | ||||
| -rw-r--r-- | cmake/Toolchain-Ubuntu-mingw32.cmake.sample | 30 | ||||
| -rw-r--r-- | cmake/modules/IntrospectSystem.cmake | 52 |
4 files changed, 144 insertions, 0 deletions
diff --git a/cmake/Toolchain-Arch-mingw32.cmake.sample b/cmake/Toolchain-Arch-mingw32.cmake.sample new file mode 100644 index 000000000..727fa04ce --- /dev/null +++ b/cmake/Toolchain-Arch-mingw32.cmake.sample @@ -0,0 +1,30 @@ +# Sample toolchain file for building for Windows from an Arch Linux system. +# +# Typical usage: +# 1) install cross compiler: `sudo pacman -S mingw32-gcc` +# 2) cp cmake/Toolchain-Arch-mingw32.cmake.sample ~/Toolchain-Arch-mingw32.cmake +# 3) tweak toolchain values as needed +# 4) cd build +# 5) cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-Arch-mingw32.cmake .. + +# name of the target OS on which the built artifacts will run +# and the toolchain prefix +set(CMAKE_SYSTEM_NAME Windows) +set(TOOLCHAIN_PREFIX i486-mingw32) + +# cross compilers to use for C and C++ +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) +set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) + +# target environment on the build host system +# set 1st to dir with the cross compiler's C/C++ headers/libs +# set 2nd to dir containing personal cross development headers/libs +set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX} ~/crossdev/w32) + +# modify default behavior of FIND_XXX() commands to +# search for headers/libs in the target environment and +# search for programs in the build 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) diff --git a/cmake/Toolchain-OSX-mingw32.cmake.sample b/cmake/Toolchain-OSX-mingw32.cmake.sample new file mode 100644 index 000000000..4926645e7 --- /dev/null +++ b/cmake/Toolchain-OSX-mingw32.cmake.sample @@ -0,0 +1,32 @@ +# Sample toolchain file for building for Windows from an OS X system. +# +# Typical usage: +# 1) install a mingw-w64 cross compiler +# a) darwin toolchain targeting win32: http://sourceforge.net/projects/mingw-w64/files/Toolchains targetting Win32/ +# b) extract toolchain into ~/mingw/w32 +# 2) cp cmake/Toolchain-OSX-mingw32.cmake.sample ~/Toolchain-OSX-mingw32.cmake +# 3) tweak toolchain values as needed +# 4) cd build +# 5) cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-OSX-mingw32.cmake .. + +# name of the target OS on which the built artifacts will run +# and the toolchain prefix +set(CMAKE_SYSTEM_NAME Windows) +set(TOOLCHAIN_PREFIX i686-w64-mingw32) + +# cross compilers to use for C and C++ +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) +set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) + +# target environment(s) on the build host system +# set 1st to dir with the cross compiler's C/C++ headers/libs +# set 2nd to dir containing personal cross development headers/libs +set(CMAKE_FIND_ROOT_PATH ~/mingw/w32/${TOOLCHAIN_PREFIX} ~/crossdev/w32) + +# modify default behavior of FIND_XXX() commands to +# search for headers/libs in the target environment and +# search for programs in the build 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) diff --git a/cmake/Toolchain-Ubuntu-mingw32.cmake.sample b/cmake/Toolchain-Ubuntu-mingw32.cmake.sample new file mode 100644 index 000000000..adc24e501 --- /dev/null +++ b/cmake/Toolchain-Ubuntu-mingw32.cmake.sample @@ -0,0 +1,30 @@ +# Sample toolchain file for building for Windows from an Ubuntu Linux system. +# +# Typical usage: +# 1) install cross compiler: `sudo apt-get install mingw-w64 g++-mingw-w64` +# 2) cp cmake/Toolchain-Ubuntu-mingw32.cmake.sample ~/Toolchain-Ubuntu-mingw32.cmake +# 3) tweak toolchain values as needed +# 4) cd build +# 5) cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-Ubuntu-mingw32.cmake .. + +# name of the target OS on which the built artifacts will run +# and the toolchain prefix +set(CMAKE_SYSTEM_NAME Windows) +set(TOOLCHAIN_PREFIX i686-w64-mingw32) + +# cross compilers to use for C and C++ +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) +set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) + +# target environment on the build host system +# set 1st to dir with the cross compiler's C/C++ headers/libs +# set 2nd to dir containing personal cross development headers/libs +set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX} ~/crossdev/w32) + +# modify default behavior of FIND_XXX() commands to +# search for headers/libs in the target environment and +# search for programs in the build 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) diff --git a/cmake/modules/IntrospectSystem.cmake b/cmake/modules/IntrospectSystem.cmake new file mode 100644 index 000000000..e148563fa --- /dev/null +++ b/cmake/modules/IntrospectSystem.cmake @@ -0,0 +1,52 @@ +# system capabilities checking + +# initial system defaults +if(CMAKE_COMPILER_IS_GNUCC) + set(MRUBY_DEFAULT_CFLAGS "-Wall -Werror-implicit-function-declaration") + set(CMAKE_C_FLAGS "${MRUBY_DEFAULT_CFLAGS}") + set(CMAKE_C_FLAGS_DEBUG "-O3 -ggdb") + set(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG") + set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g") + set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") + + set(MRUBY_LIBS m) +else() + if(MSVC) + # TODO default MSVC flags + add_definitions( + -D_CRT_SECURE_NO_WARNINGS + -wd4018 # suppress 'signed/unsigned mismatch' + ) + endif() +endif() + +if(MSVC) + add_definitions( + -DRUBY_EXPORT # required by oniguruma.h + ) +endif() + + +# include helpers +include(CheckIncludeFile) +include(CheckSymbolExists) + +# header checks +CHECK_INCLUDE_FILE(string.h HAVE_STRING_H) +if(HAVE_STRING_H) + add_definitions(-DHAVE_STRING_H) +endif() + +CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H) +if(HAVE_FLOAT_H) + add_definitions(-DHAVE_FLOAT_H) +endif() + + +# symbol checks +CHECK_SYMBOL_EXISTS(gettimeofday sys/time.h HAVE_GETTIMEOFDAY) +if(NOT HAVE_GETTIMEOFDAY) + add_definitions(-DNO_GETTIMEOFDAY) +endif() + +# vim: ts=2 sts=2 sw=2 et |
