From 0ec2f0f11f8b044e4f85dbc3e19cab67fd2400a8 Mon Sep 17 00:00:00 2001 From: Pierre Habouzit Date: Sun, 23 Sep 2007 14:24:56 +0200 Subject: [PATCH] Import cmaked Signed-off-by: Pierre Habouzit --- CMakeLists.txt | 16 +- cmake/Modules/CMakeDCompiler.cmake.in | 45 ++++ cmake/Modules/CMakeDInformation.cmake | 237 ++++++++++++++++++++ cmake/Modules/CMakeDetermineDCompiler.cmake | 108 +++++++++ cmake/Modules/CMakeTestDCompiler.cmake | 175 +++++++++++++++ cmake/{ => Modules}/CheckStructMember.cmake | 0 cmake/Modules/Copyright.txt | 30 +++ cmake/{ => Modules}/Cpkg2c.cmake | 0 cmake/Modules/FindGDCPath.cmake | 43 ++++ cmake/Modules/Platform/Linux-dmd.cmake | 35 +++ cmake/Modules/Platform/Linux-gdc.cmake | 36 +++ cmake/Modules/Platform/Windows-dmd.cmake | 36 +++ cmake/Modules/Platform/Windows-gdc.cmake | 36 +++ cmake/Modules/UseDDoc.cmake | 61 +++++ cmake/{ => Modules}/XConfig.cmake | 0 configure | 2 +- 16 files changed, 854 insertions(+), 6 deletions(-) create mode 100644 cmake/Modules/CMakeDCompiler.cmake.in create mode 100644 cmake/Modules/CMakeDInformation.cmake create mode 100644 cmake/Modules/CMakeDetermineDCompiler.cmake create mode 100644 cmake/Modules/CMakeTestDCompiler.cmake rename cmake/{ => Modules}/CheckStructMember.cmake (100%) create mode 100644 cmake/Modules/Copyright.txt rename cmake/{ => Modules}/Cpkg2c.cmake (100%) create mode 100644 cmake/Modules/FindGDCPath.cmake create mode 100644 cmake/Modules/Platform/Linux-dmd.cmake create mode 100644 cmake/Modules/Platform/Linux-gdc.cmake create mode 100644 cmake/Modules/Platform/Windows-dmd.cmake create mode 100644 cmake/Modules/Platform/Windows-gdc.cmake create mode 100644 cmake/Modules/UseDDoc.cmake rename cmake/{ => Modules}/XConfig.cmake (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33cd4f6..229f832 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,16 @@ -PROJECT(madmutt C) +SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules) + +PROJECT(madmutt C D) SET(PACKAGE madmutt) -SET(CMAKE_MODULE_PATH ${madmutt_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) -# TODO {{{ -# USE_SETGID -# }}} +# Using Phobos OR Tango (can be specified from cmake command line) +if (NOT CMAKE_D_USE_PHOBOS AND NOT CMAKE_D_USE_TANGO) + # default to phobos + message(STATUS "This application can be built with either Phobos or Tango!") + message(STATUS "You did not specify a standard library -- defaulting to Phobos.") + message(STATUS "If you wish to use Tango add -DCMAKE_D_USE_TANGO=True to cmake command line.") + set(CMAKE_D_USE_PHOBOS True) +endif (NOT CMAKE_D_USE_PHOBOS AND NOT CMAKE_D_USE_TANGO) INCLUDE(CMakeDetermineCCompiler) include(Cpkg2c) diff --git a/cmake/Modules/CMakeDCompiler.cmake.in b/cmake/Modules/CMakeDCompiler.cmake.in new file mode 100644 index 0000000..6d18e3a --- /dev/null +++ b/cmake/Modules/CMakeDCompiler.cmake.in @@ -0,0 +1,45 @@ +# +# CMakeD - CMake module for D Language +# +# Copyright (c) 2007, Selman Ulug +# Tim Burrell +# +# All rights reserved. +# +# See Copyright.txt for details. +# +# Modified from CMake 2.6.5 CMakeCCompiler.cmake.in +# See http://www.cmake.org/HTML/Copyright.html for details +# + +SET(CMAKE_D_COMPILER "@CMAKE_D_COMPILER@") +SET(CMAKE_D_COMPILER_ARG1 "@CMAKE_D_COMPILER_ARG1@") +SET(CMAKE_AR "@CMAKE_AR@") +SET(CMAKE_RANLIB "@CMAKE_RANLIB@") +SET(CMAKE_COMPILER_IS_GDC @CMAKE_COMPILER_IS_GDC@) +SET(CMAKE_COMPILER_IS_DMD @CMAKE_COMPILER_IS_DMD@) +SET(CMAKE_D_COMPILER_LOADED 1) +SET(CMAKE_COMPILER_IS_MINGW @CMAKE_COMPILER_IS_MINGW@) +SET(CMAKE_COMPILER_IS_CYGWIN @CMAKE_COMPILER_IS_CYGWIN@) +IF(CMAKE_COMPILER_IS_CYGWIN) + SET(CYGWIN 1) + SET(UNIX 1) +ENDIF(CMAKE_COMPILER_IS_CYGWIN) + +SET(CMAKE_D_COMPILER_ENV_VAR "DC") + +IF(CMAKE_COMPILER_IS_MINGW) + SET(MINGW 1) +ENDIF(CMAKE_COMPILER_IS_MINGW) +SET(CMAKE_COMPILER_IS_GDC_RUN 1) +SET(CMAKE_D_SOURCE_FILE_EXTENSIONS d) +SET(CMAKE_D_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) +SET(CMAKE_D_LINKER_PREFERENCE None) +IF(UNIX) + SET(CMAKE_D_OUTPUT_EXTENSION .o) +ELSE(UNIX) + SET(CMAKE_D_OUTPUT_EXTENSION .obj) +ENDIF(UNIX) +# save the size of void* in case where cache is removed +# and the this file is still around +#SET(CMAKE_SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@) diff --git a/cmake/Modules/CMakeDInformation.cmake b/cmake/Modules/CMakeDInformation.cmake new file mode 100644 index 0000000..2e2620a --- /dev/null +++ b/cmake/Modules/CMakeDInformation.cmake @@ -0,0 +1,237 @@ +# +# CMakeD - CMake module for D Language +# +# Copyright (c) 2007, Selman Ulug +# Tim Burrell +# +# All rights reserved. +# +# See Copyright.txt for details. +# +# Modified from CMake 2.6.5 CMakeCInformation.cmake +# See http://www.cmake.org/HTML/Copyright.html for details +# + +# This file sets the basic flags for the D language in CMake. +# It also loads the available platform file for the system-compiler +# if it exists. + +GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_D_COMPILER} NAME_WE) +IF(CMAKE_COMPILER_IS_GDC) + SET(CMAKE_BASE_NAME gdc) +ELSE(CMAKE_COMPILER_IS_GDC) + SET(CMAKE_BASE_NAME dmd) +ENDIF(CMAKE_COMPILER_IS_GDC) +SET(CMAKE_SYSTEM_AND_D_COMPILER_INFO_FILE + ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake) +INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL) + +# This should be included before the _INIT variables are +# used to initialize the cache. Since the rule variables +# have if blocks on them, users can still define them here. +# But, it should still be after the platform file so changes can +# be made to those values. + +IF(CMAKE_USER_MAKE_RULES_OVERRIDE) + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE}) +ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE) + +IF(CMAKE_USER_MAKE_RULES_OVERRIDE_D) + INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_D}) +ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE_D) + +# for most systems a module is the same as a shared library +# so unless the variable CMAKE_MODULE_EXISTS is set just +# copy the values from the LIBRARY variables +IF(NOT CMAKE_MODULE_EXISTS) + SET(CMAKE_SHARED_MODULE_D_FLAGS ${CMAKE_SHARED_LIBRARY_D_FLAGS}) + SET(CMAKE_SHARED_MODULE_CREATE_D_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_D_FLAGS}) +ENDIF(NOT CMAKE_MODULE_EXISTS) + +SET (CMAKE_D_FLAGS "$ENV{CFLAGS} ${CMAKE_D_FLAGS_INIT}" CACHE STRING + "Flags for D compiler.") + +IF(NOT CMAKE_NOT_USING_CONFIG_FLAGS) +# default build type is none + IF(NOT CMAKE_NO_BUILD_TYPE) + SET (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING + "Choose the type of build, options are: None(CMAKE_D_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") + ENDIF(NOT CMAKE_NO_BUILD_TYPE) + SET (CMAKE_D_FLAGS_DEBUG "${CMAKE_D_FLAGS_DEBUG_INIT}" CACHE STRING + "Flags used by the compiler during debug builds.") + SET (CMAKE_D_FLAGS_MINSIZEREL "${CMAKE_D_FLAGS_MINSIZEREL_INIT}" CACHE STRING + "Flags used by the compiler during release minsize builds.") + SET (CMAKE_D_FLAGS_RELEASE "${CMAKE_D_FLAGS_RELEASE_INIT}" CACHE STRING + "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") + SET (CMAKE_D_FLAGS_RELWITHDEBINFO "${CMAKE_D_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING + "Flags used by the compiler during Release with Debug Info builds.") +ENDIF(NOT CMAKE_NOT_USING_CONFIG_FLAGS) + +IF(CMAKE_D_STANDARD_LIBRARIES_INIT) + SET(CMAKE_D_STANDARD_LIBRARIES "${CMAKE_D_STANDARD_LIBRARIES_INIT}" + CACHE STRING "Libraries linked by defalut with all D applications.") + MARK_AS_ADVANCED(CMAKE_D_STANDARD_LIBRARIES) +ENDIF(CMAKE_D_STANDARD_LIBRARIES_INIT) + +INCLUDE(CMakeCommonLanguageInclude) + +# now define the following rule variables + +# CMAKE_D_CREATE_SHARED_LIBRARY +# CMAKE_D_CREATE_SHARED_MODULE +# CMAKE_D_CREATE_STATIC_LIBRARY +# CMAKE_D_COMPILE_OBJECT +# CMAKE_D_LINK_EXECUTABLE + +# variables supplied by the generator at use time +# +# the target without the suffix +# +# +# +# +# + +# D compiler information +# +# +# +# + +# Static library tools +# +# + +IF("$ENV{D_PATH}" STREQUAL "") + STRING(LENGTH ${CMAKE_D_COMPILER} CMAKE_D_COMPILER_LENGTH) + IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + MATH(EXPR CMAKE_D_COMPILER_LENGTH "${CMAKE_D_COMPILER_LENGTH} - 12") + ELSE(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + MATH(EXPR CMAKE_D_COMPILER_LENGTH "${CMAKE_D_COMPILER_LENGTH} - 8") + ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + STRING(SUBSTRING ${CMAKE_D_COMPILER} 0 ${CMAKE_D_COMPILER_LENGTH} D_PATH) +ELSE("$ENV{D_PATH}" STREQUAL "") + SET(D_PATH "$ENV{D_PATH}") +ENDIF("$ENV{D_PATH}" STREQUAL "") +MESSAGE(STATUS "D Compiler Install Prefix (use D_PATH env var to override): ${D_PATH}") + +IF(CMAKE_COMPILER_IS_GDC) + SET(CMAKE_OUTPUT_D_FLAG "-o ") + SET(CMAKE_SHARED_LIBRARY_D_FLAGS "-fPIC") + SET(CMAKE_SHARED_LIBRARY_CREATE_D_FLAGS "-shared") + SET(CMAKE_INCLUDE_FLAG_D "-I") # -I + SET(CMAKE_INCLUDE_FLAG_D_SEP "") # , or empty + SET(CMAKE_LIBRARY_PATH_FLAG "-L") + SET(CMAKE_LINK_LIBRARY_FLAG "-l") + SET(CMAKE_D_VERSION_FLAG "-fversion=") +ELSE(CMAKE_COMPILER_IS_GDC) + SET(CMAKE_OUTPUT_D_FLAG "-of") + SET(CMAKE_D_VERSION_FLAG "-version=") + IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + SET(CMAKE_INCLUDE_FLAG_D "-I") # -I + SET(CMAKE_INCLUDE_FLAG_D_SEP "") # , or empty + SET(CMAKE_LINK_LIBRARY_FLAG "-L+") + SET(CMAKE_LIBRARY_PATH_FLAG "-L+") + SET(CMAKE_LIBRARY_PATH_TERMINATOR "\\") + FIND_PROGRAM(DMD_LIBRARIAN "lib.exe") + ELSE(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + SET(CMAKE_SHARED_LIBRARY_D_FLAGS "-fPIC") + SET(CMAKE_SHARED_LIBRARY_CREATE_D_FLAGS "-shared") + SET(CMAKE_INCLUDE_FLAG_D "-I") # -I + SET(CMAKE_INCLUDE_FLAG_D_SEP "") # , or empty + SET(CMAKE_LIBRARY_PATH_FLAG "-L") + ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") +ENDIF(CMAKE_COMPILER_IS_GDC) + +IF(CMAKE_D_USE_TANGO) + IF(CMAKE_COMPILER_IS_GDC) + SET(DSTDLIB_TYPE "-fversion=Tango") + SET(DSTDLIB_FLAGS "-lgtango") + ELSE(CMAKE_COMPILER_IS_GDC) + SET(DSTDLIB_TYPE "-version=Tango") + SET(DSTDLIB_FLAGS "-L${D_PATH}/lib -ltango -lphobos") + ENDIF(CMAKE_COMPILER_IS_GDC) +ENDIF(CMAKE_D_USE_TANGO) +IF(CMAKE_D_USE_PHOBOS) + IF(CMAKE_COMPILER_IS_GDC) + SET(DSTDLIB_TYPE "-fversion=Phobos") + SET(DSTDLIB_FLAGS "-lgphobos") + ELSE(CMAKE_COMPILER_IS_GDC) + SET(DSTDLIB_TYPE "-version=Phobos") + SET(DSTDLIB_FLAGS "-L${D_PATH}/lib -lphobos") + ENDIF(CMAKE_COMPILER_IS_GDC) +ENDIF(CMAKE_D_USE_PHOBOS) + +# create a D shared library +IF(NOT CMAKE_D_CREATE_SHARED_LIBRARY) + IF(CMAKE_COMPILER_IS_GDC) + SET(CMAKE_D_CREATE_SHARED_LIBRARY + " ${CMAKE_OUTPUT_D_FLAG} ") + ELSE(CMAKE_COMPILER_IS_GDC) + SET(CMAKE_D_CREATE_SHARED_LIBRARY + " ${CMAKE_OUTPUT_D_FLAG} ${DSTDLIB_FLAGS}") + ENDIF(CMAKE_COMPILER_IS_GDC) +ENDIF(NOT CMAKE_D_CREATE_SHARED_LIBRARY) + +# create a D shared module just copy the shared library rule +IF(NOT CMAKE_D_CREATE_SHARED_MODULE) + SET(CMAKE_D_CREATE_SHARED_MODULE ${CMAKE_D_CREATE_SHARED_LIBRARY}) +ENDIF(NOT CMAKE_D_CREATE_SHARED_MODULE) + +# create a D static library +IF(NOT CMAKE_D_CREATE_STATIC_LIBRARY) + IF(CMAKE_COMPILER_IS_GDC) + IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + SET(CMAKE_D_CREATE_STATIC_LIBRARY + " cr .lib " + " .lib " + " cr " + " " + ) + ELSE(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + SET(CMAKE_D_CREATE_STATIC_LIBRARY + " cr " + " " + ) + ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + ELSE(CMAKE_COMPILER_IS_GDC) + IF(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + SET(CMAKE_D_CREATE_STATIC_LIBRARY + " cr " + " ") + ELSE(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + SET(CMAKE_D_CREATE_STATIC_LIBRARY + "${DMD_LIBRARIAN} -c -p256 ") + ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + ENDIF(CMAKE_COMPILER_IS_GDC) +ENDIF(NOT CMAKE_D_CREATE_STATIC_LIBRARY) + +# compile a D file into an object file +IF(NOT CMAKE_D_COMPILE_OBJECT) + SET(CMAKE_D_COMPILE_OBJECT + " ${CMAKE_OUTPUT_D_FLAG} -c ") +ENDIF(NOT CMAKE_D_COMPILE_OBJECT) + +IF(NOT CMAKE_D_LINK_EXECUTABLE) + IF(CMAKE_COMPILER_IS_GDC) + SET(CMAKE_D_LINK_EXECUTABLE + " ${CMAKE_OUTPUT_D_FLAG} ${DSTDLIB_FLAGS} ${DSTDLIB_TYPE}") + ELSE(CMAKE_COMPILER_IS_GDC) + IF(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + SET(CMAKE_D_LINK_EXECUTABLE + "gcc ${DLINK_FLAGS} -o -lpthread -lm ${DSTDLIB_FLAGS}") + ELSE(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + SET(CMAKE_D_LINK_EXECUTABLE + " ${CMAKE_OUTPUT_D_FLAG} ") + ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + ENDIF(CMAKE_COMPILER_IS_GDC) +ENDIF(NOT CMAKE_D_LINK_EXECUTABLE) + +MARK_AS_ADVANCED( +CMAKE_D_FLAGS +CMAKE_D_FLAGS_DEBUG +CMAKE_D_FLAGS_MINSIZEREL +CMAKE_D_FLAGS_RELEASE +CMAKE_D_FLAGS_RELWITHDEBINFO +) +SET(CMAKE_D_INFORMATION_LOADED 1) diff --git a/cmake/Modules/CMakeDetermineDCompiler.cmake b/cmake/Modules/CMakeDetermineDCompiler.cmake new file mode 100644 index 0000000..1655dbf --- /dev/null +++ b/cmake/Modules/CMakeDetermineDCompiler.cmake @@ -0,0 +1,108 @@ +# +# CMakeD - CMake module for D Language +# +# Copyright (c) 2007, Selman Ulug +# Tim Burrell +# +# All rights reserved. +# +# See Copyright.txt for details. +# +# Modified from CMake 2.6.5 CMakeDetermineCCompiler.cmake +# See http://www.cmake.org/HTML/Copyright.html for details +# + +# determine the compiler to use for D programs +# NOTE, a generator may set CMAKE_D_COMPILER before +# loading this file to force a compiler. +# use environment variable DC first if defined by user, next use +# the cmake variable CMAKE_GENERATOR_D which can be defined by a generator +# as a default compiler + +IF(NOT CMAKE_D_COMPILER) + + # prefer the environment variable DC + IF($ENV{DC} MATCHES ".+") + GET_FILENAME_COMPONENT(CMAKE_D_COMPILER_INIT $ENV{DC} PROGRAM PROGRAM_ARGS CMAKE_D_FLAGS_ENV_INIT) + IF(CMAKE_D_FLAGS_ENV_INIT) + SET(CMAKE_D_COMPILER_ARG1 "${CMAKE_D_FLAGS_ENV_INIT}" CACHE STRING "First argument to D compiler") + ENDIF(CMAKE_D_FLAGS_ENV_INIT) + IF(EXISTS ${CMAKE_D_COMPILER_INIT}) + ELSE(EXISTS ${CMAKE_D_COMPILER_INIT}) + MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable C:\n$ENV{DC}.") + ENDIF(EXISTS ${CMAKE_D_COMPILER_INIT}) + ENDIF($ENV{DC} MATCHES ".+") + + # next try prefer the compiler specified by the generator + IF(CMAKE_GENERATOR_D) + IF(NOT CMAKE_D_COMPILER_INIT) + SET(CMAKE_D_COMPILER_INIT ${CMAKE_GENERATOR_D}) + ENDIF(NOT CMAKE_D_COMPILER_INIT) + ENDIF(CMAKE_GENERATOR_D) + + # finally list compilers to try + IF(CMAKE_D_COMPILER_INIT) + SET(CMAKE_D_COMPILER_LIST ${CMAKE_D_COMPILER_INIT}) + ELSE(CMAKE_D_COMPILER_INIT) + SET(CMAKE_D_COMPILER_LIST gdc dmd) + ENDIF(CMAKE_D_COMPILER_INIT) + + # Find the compiler. + FIND_PROGRAM(CMAKE_D_COMPILER NAMES ${CMAKE_D_COMPILER_LIST} DOC "C compiler") + IF(CMAKE_D_COMPILER_INIT AND NOT CMAKE_D_COMPILER) + SET(CMAKE_D_COMPILER "${CMAKE_D_COMPILER_INIT}" CACHE FILEPATH "C compiler" FORCE) + ENDIF(CMAKE_D_COMPILER_INIT AND NOT CMAKE_D_COMPILER) +ENDIF(NOT CMAKE_D_COMPILER) +MARK_AS_ADVANCED(CMAKE_D_COMPILER) +GET_FILENAME_COMPONENT(COMPILER_LOCATION "${CMAKE_D_COMPILER}" PATH) + +FIND_PROGRAM(CMAKE_AR NAMES ar PATHS ${COMPILER_LOCATION} ) + +FIND_PROGRAM(CMAKE_RANLIB NAMES ranlib) +IF(NOT CMAKE_RANLIB) + SET(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib") +ENDIF(NOT CMAKE_RANLIB) +MARK_AS_ADVANCED(CMAKE_RANLIB) + +# do not test for GNU if the generator is visual studio +IF(${CMAKE_GENERATOR} MATCHES "Visual Studio") + SET(CMAKE_COMPILER_IS_GDC_RUN 1) +ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio") + + +IF(NOT CMAKE_COMPILER_IS_GDC_RUN) + # test to see if the d compiler is gdc + SET(CMAKE_COMPILER_IS_GDC_RUN 1) + IF("${CMAKE_D_COMPILER}" MATCHES ".*gdc.*" ) + SET(CMAKE_COMPILER_IS_GDC 1) + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the D compiler is GDC succeeded with " + "the following output:\n${CMAKE_D_COMPILER}\n\n") + EXEC_PROGRAM(${CMAKE_D_COMPILER} ARGS "--version" OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT) + IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*mingw.*" ) + SET(CMAKE_COMPILER_IS_MINGW 1) + ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*mingw.*" ) + IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_CYGWIN.*" ) + SET(CMAKE_COMPILER_IS_CYGWIN 1) + ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_CYGWIN.*" ) + ELSE("${CMAKE_D_COMPILER}" MATCHES ".*dmd.*" ) + SET(CMAKE_COMPILER_IS_DMD 1) + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the D compiler is DMD succeeded with " + "the following output:\n${CMAKE_D_COMPILER}\n\n") + ENDIF("${CMAKE_D_COMPILER}" MATCHES ".*gdc.*" ) +ENDIF(NOT CMAKE_COMPILER_IS_GDC_RUN) + + +# configure variables set in this file for fast reload later on +IF(EXISTS ${CMAKE_SOURCE_DIR}/cmake/Modules/CMakeDCompiler.cmake.in) + CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/Modules/CMakeDCompiler.cmake.in + "${CMAKE_PLATFORM_ROOT_BIN}/CMakeDCompiler.cmake" IMMEDIATE) +ELSE(EXISTS ${CMAKE_SOURCE_DIR}/cmake/Modules/CMakeDCompiler.cmake.in) + CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeDCompiler.cmake.in + "${CMAKE_PLATFORM_ROOT_BIN}/CMakeDCompiler.cmake" IMMEDIATE) +ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/cmake/Modules/CMakeDCompiler.cmake.in) + +MARK_AS_ADVANCED(CMAKE_AR) +SET(CMAKE_D_COMPILER_ENV_VAR "DC") + diff --git a/cmake/Modules/CMakeTestDCompiler.cmake b/cmake/Modules/CMakeTestDCompiler.cmake new file mode 100644 index 0000000..4fb7c7c --- /dev/null +++ b/cmake/Modules/CMakeTestDCompiler.cmake @@ -0,0 +1,175 @@ +# +# CMakeD - CMake module for D Language +# +# Copyright (c) 2007, Selman Ulug +# Tim Burrell +# +# All rights reserved. +# +# See Copyright.txt for details. +# +# Modified from CMake 2.6.5 CMakeTestCCompiler.cmake +# See http://www.cmake.org/HTML/Copyright.html for details +# + +# This file is used by EnableLanguage in cmGlobalGenerator to +# determine that that selected D compiler can actually compile +# and link the most basic of programs. If not, a fatal error +# is set and cmake stops processing commands and will not generate +# any makefiles or projects. + +IF(NOT CMAKE_D_COMPILER_WORKS) + MESSAGE(STATUS "Check for working D compiler: ${CMAKE_D_COMPILER}") + FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testDCompiler.d + "int main(char[][] args)\n" + "{return args.sizeof-1;}\n") + STRING(REGEX MATCH "dmd" DMDTEST "${CMAKE_D_COMPILER}") + IF(DMDTEST STREQUAL "dmd") + IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + TRY_COMPILE(CMAKE_D_COMPILER_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testDCompiler.d + OUTPUT_VARIABLE OUTPUT) + ELSE(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + TRY_COMPILE(CMAKE_D_COMPILER_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testDCompiler.d + CMAKE_FLAGS "-DLINK_LIBRARIES=${D_PATH}/lib/libphobos.a" + OUTPUT_VARIABLE OUTPUT) + ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + ELSE(DMDTEST STREQUAL "dmd") + TRY_COMPILE(CMAKE_D_COMPILER_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testDCompiler.d + OUTPUT_VARIABLE OUTPUT) + ENDIF(DMDTEST STREQUAL "dmd") + SET(C_TEST_WAS_RUN 1) +ENDIF(NOT CMAKE_D_COMPILER_WORKS) + +IF(NOT CMAKE_D_COMPILER_WORKS) + MESSAGE(STATUS "Check for working D compiler: ${CMAKE_D_COMPILER} -- broken") + message(STATUS "To force a specific D compiler set the DC environment variable") + message(STATUS " ie - export DC=\"/opt/dmd/bin/dmd\"") + message(STATUS "If the D path is not set please use the D_PATH variable") + message(STATUS " ie - export D_PATH=\"/opt/dmd\"") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the D compiler works failed with " + "the following output:\n${OUTPUT}\n\n") + MESSAGE(FATAL_ERROR "The D compiler \"${CMAKE_D_COMPILER}\" " + "is not able to compile a simple test program.\nIt fails " + "with the following output:\n ${OUTPUT}\n\n" + "CMake will not be able to correctly generate this project.") +ELSE(NOT CMAKE_D_COMPILER_WORKS) + IF(C_TEST_WAS_RUN) + MESSAGE(STATUS "Check for working D compiler: ${CMAKE_D_COMPILER} -- works") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the D compiler works passed with " + "the following output:\n${OUTPUT}\n\n") + ENDIF(C_TEST_WAS_RUN) + SET(CMAKE_D_COMPILER_WORKS 1 CACHE INTERNAL "") + # re-configure this file CMakeDCompiler.cmake so that it gets + # the value for CMAKE_SIZEOF_VOID_P + # configure variables set in this file for fast reload later on + IF(EXISTS ${CMAKE_SOURCE_DIR}/cmake/Modules/CMakeDCompiler.cmake.in) + CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/Modules/CMakeDCompiler.cmake.in + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeDCompiler.cmake IMMEDIATE) + ELSE(EXISTS ${CMAKE_SOURCE_DIR}/cmake/Modules/CMakeDCompiler.cmake.in) + CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeDCompiler.cmake.in + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeDCompiler.cmake IMMEDIATE) + ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/cmake/Modules/CMakeDCompiler.cmake.in) +ENDIF(NOT CMAKE_D_COMPILER_WORKS) + +IF(NOT CMAKE_D_PHOBOS_WORKS) + MESSAGE(STATUS "Check for working Phobos") + FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testDCompiler.d + "import std.stdio;\n" + "int main(char[][] args)\n" + "{ writefln(\"%s\", args[0]); return args.sizeof-1;}\n") + IF(CMAKE_COMPILER_IS_GDC) + IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + TRY_COMPILE(CMAKE_D_PHOBOS_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testDCompiler.d + #CMAKE_FLAGS "-DLINK_LIBRARIES=gphobos" + OUTPUT_VARIABLE OUTPUT) + ELSE(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + TRY_COMPILE(CMAKE_D_PHOBOS_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testDCompiler.d + CMAKE_FLAGS "-DLINK_LIBRARIES=gphobos" + OUTPUT_VARIABLE OUTPUT) + ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + ELSE(CMAKE_COMPILER_IS_GDC) + IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + TRY_COMPILE(CMAKE_D_PHOBOS_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testDCompiler.d + OUTPUT_VARIABLE OUTPUT) + ELSE(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + TRY_COMPILE(CMAKE_D_PHOBOS_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testDCompiler.d + CMAKE_FLAGS "-DLINK_LIBRARIES=${D_PATH}/lib/libphobos.a" + COMPILE_DEFINITIONS "-I${D_PATH}/include -I${D_PATH}/import" + OUTPUT_VARIABLE OUTPUT) + ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + ENDIF(CMAKE_COMPILER_IS_GDC) + SET(C_TEST_WAS_RUN 1) +ENDIF(NOT CMAKE_D_PHOBOS_WORKS) + +IF(NOT CMAKE_D_PHOBOS_WORKS) + MESSAGE(STATUS "Check for working Phobos -- unavailable") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if Phobos works failed with " + "the following output:\n${OUTPUT}\n\n") + #MESSAGE(FATAL_ERROR "Phobos does not work") +ELSE(NOT CMAKE_D_PHOBOS_WORKS) + IF(C_TEST_WAS_RUN) + MESSAGE(STATUS "Check for working Phobos -- works") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if Phobos works passed with " + "the following output:\n${OUTPUT}\n\n") + ENDIF(C_TEST_WAS_RUN) + SET(CMAKE_D_PHOBOS_WORKS 1 CACHE INTERNAL "") +ENDIF(NOT CMAKE_D_PHOBOS_WORKS) + +IF(NOT CMAKE_D_TANGO_WORKS) + MESSAGE(STATUS "Check for working Tango") + FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testDCompiler.d + "import tango.io.Stdout;" + "int main(char[][] args)\n" + "{Stdout.newline();return args.sizeof-1;}\n") + IF(CMAKE_COMPILER_IS_GDC) + TRY_COMPILE(CMAKE_D_TANGO_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testDCompiler.d + CMAKE_FLAGS "-DLINK_LIBRARIES=gtango" + OUTPUT_VARIABLE OUTPUT) + ELSE(CMAKE_COMPILER_IS_GDC) + IF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + TRY_COMPILE(CMAKE_D_TANGO_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testDCompiler.d + OUTPUT_VARIABLE OUTPUT) + ELSE(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + TRY_COMPILE(CMAKE_D_TANGO_WORKS ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testDCompiler.d + CMAKE_FLAGS "-DLINK_LIBRARIES=${D_PATH}/lib/libtango.a;${D_PATH}/lib/libphobos.a" + COMPILE_DEFINITIONS "-I${D_PATH}/include -I${D_PATH}/import" + OUTPUT_VARIABLE OUTPUT) + ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + ENDIF(CMAKE_COMPILER_IS_GDC) + SET(C_TEST_WAS_RUN 1) +ENDIF(NOT CMAKE_D_TANGO_WORKS) + +IF(NOT CMAKE_D_TANGO_WORKS) + MESSAGE(STATUS "Check for working Tango -- unavailable") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if Tango works failed with " + "the following output:\n${OUTPUT}\n\n") + #MESSAGE(FATAL_ERROR "Tango does not work: \n${OUTPUT}\n\n") +ELSE(NOT CMAKE_D_TANGO_WORKS) + IF(C_TEST_WAS_RUN) + MESSAGE(STATUS "Check for working Tango -- works") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if Tango works passed with " + "the following output:\n${OUTPUT}\n\n") + ENDIF(C_TEST_WAS_RUN) + SET(CMAKE_D_TANGO_WORKS 1 CACHE INTERNAL "") +ENDIF(NOT CMAKE_D_TANGO_WORKS) + +# if both tango and phobos are selected try to choose which one is available +IF(CMAKE_D_USE_TANGO AND CMAKE_D_USE_PHOBOS) + MESSAGE(FATAL_ERROR "Tango AND Phobos selected, please choose one or the other!") +ENDIF(CMAKE_D_USE_TANGO AND CMAKE_D_USE_PHOBOS) + +# ensure the user has the appropriate std lib available +IF(CMAKE_D_USE_TANGO AND NOT CMAKE_D_TANGO_WORKS) + MESSAGE(FATAL_ERROR "Tango is required for this project, but it is not available!") +ENDIF(CMAKE_D_USE_TANGO AND NOT CMAKE_D_TANGO_WORKS) + +IF(CMAKE_D_USE_PHOBOS AND NOT CMAKE_D_PHOBOS_WORKS) + MESSAGE(FATAL_ERROR "Phobos is required for this project, but it is not available!") +ENDIF(CMAKE_D_USE_PHOBOS AND NOT CMAKE_D_PHOBOS_WORKS) + diff --git a/cmake/CheckStructMember.cmake b/cmake/Modules/CheckStructMember.cmake similarity index 100% rename from cmake/CheckStructMember.cmake rename to cmake/Modules/CheckStructMember.cmake diff --git a/cmake/Modules/Copyright.txt b/cmake/Modules/Copyright.txt new file mode 100644 index 0000000..59051ed --- /dev/null +++ b/cmake/Modules/Copyright.txt @@ -0,0 +1,30 @@ +CMakeD - CMake module for D Language + +Copyright (c) 2007, Selman Ulug + Tim Burrell + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/cmake/Cpkg2c.cmake b/cmake/Modules/Cpkg2c.cmake similarity index 100% rename from cmake/Cpkg2c.cmake rename to cmake/Modules/Cpkg2c.cmake diff --git a/cmake/Modules/FindGDCPath.cmake b/cmake/Modules/FindGDCPath.cmake new file mode 100644 index 0000000..e388ffa --- /dev/null +++ b/cmake/Modules/FindGDCPath.cmake @@ -0,0 +1,43 @@ +# +# CMakeD - CMake module for D Language +# +# Copyright (c) 2007, Selman Ulug +# Tim Burrell +# +# All rights reserved. +# +# See Copyright.txt for details. +# + + +# - Find GDC Include Path +# +# GDC_INCLUDE_PATH = path to where object.d is found +# + +SET(GDC_POSSIBLE_INCLUDE_PATHS + /usr/include/d/4.2.1 + /usr/include/d/4.2.0 + /usr/include/d/4.1.2 + /usr/include/d/4.1.1 + /usr/include/d/4.1.0 + /usr/include/d/4.0.4 + /usr/include/d/4.0.3 + /usr/include/d/4.0.2 + /usr/include/d/4.0.1 + /usr/include/d/4.0.0 + /usr/include/d/4.0.6 + /usr/include/d/4.0.5 + /usr/include/d/3.4.4 + /usr/include/d/3.4.3 + /usr/include/d/3.4.2 + /usr/include/d/3.4.1 + /usr/include/d/3.4.0 + ) + +FIND_PATH(GDC_INCLUDE_PATH object.d + ${GDC_POSSIBLE_INCLUDE_PATHS}) + +MARK_AS_ADVANCED( + GDC_INCLUDE_PATH + ) diff --git a/cmake/Modules/Platform/Linux-dmd.cmake b/cmake/Modules/Platform/Linux-dmd.cmake new file mode 100644 index 0000000..f9c3009 --- /dev/null +++ b/cmake/Modules/Platform/Linux-dmd.cmake @@ -0,0 +1,35 @@ +# +# CMakeD - CMake module for D Language +# +# Copyright (c) 2007, Selman Ulug +# Tim Burrell +# +# All rights reserved. +# +# See Copyright.txt for details. +# +# Modified from CMake 2.6.5 gcc.cmake +# See http://www.cmake.org/HTML/Copyright.html for details +# + +IF(CMAKE_D_USE_TANGO) + SET(DSTDLIB_FLAGS "-version=Tango") +ENDIF(CMAKE_D_USE_TANGO) +IF(CMAKE_D_USE_PHOBOS) + SET(DSTDLIB_FLAGS "-version=Phobos") +ENDIF(CMAKE_D_USE_PHOBOS) +IF(CMAKE_D_BUILD_DOCS) + SET(DDOC_FLAGS "-D -Dddocumentation") + #FOREACH(item ${CMAKE_D_DDOC_FILES}) + # SET(DDOC_FLAGS "${DDOC_FLAGS} ${item}") + #ENDFOREACH(item) +ENDIF(CMAKE_D_BUILD_DOCS) + +SET (CMAKE_D_FLAGS_INIT "-version=Posix ${DSTDLIB_FLAGS} -I$ENV{D_PATH}/include -I$ENV{D_PATH}/import") +SET (CMAKE_D_FLAGS_DEBUG_INIT "-g ${DDOC_FLAGS}") +# SET (CMAKE_D_FLAGS_MINSIZEREL_INIT "-Os ${DDOC_FLAGS}") +SET (CMAKE_D_FLAGS_RELEASE_INIT "-O -release -inline ${DDOC_FLAGS}") +SET (CMAKE_D_FLAGS_RELWITHDEBINFO_INIT "-O -g ${DDOC_FLAGS}") +# SET (CMAKE_D_CREATE_PREPROCESSED_SOURCE " -E > ") +SET (CMAKE_D_CREATE_ASSEMBLY_SOURCE " -S -o ") +# SET (CMAKE_INCLUDE_SYSTEM_FLAG_D "-isystem ") diff --git a/cmake/Modules/Platform/Linux-gdc.cmake b/cmake/Modules/Platform/Linux-gdc.cmake new file mode 100644 index 0000000..8e8af9a --- /dev/null +++ b/cmake/Modules/Platform/Linux-gdc.cmake @@ -0,0 +1,36 @@ +# +# CMakeD - CMake module for D Language +# +# Copyright (c) 2007, Selman Ulug +# Tim Burrell +# +# All rights reserved. +# +# See Copyright.txt for details. +# +# Modified from CMake 2.6.5 gcc.cmake +# See http://www.cmake.org/HTML/Copyright.html for details +# + +IF(CMAKE_D_USE_TANGO) + SET(DSTDLIB_FLAGS "-fversion=Tango") +ENDIF(CMAKE_D_USE_TANGO) +IF(CMAKE_D_USE_PHOBOS) + SET(DSTDLIB_FLAGS "-fversion=Phobos") +ENDIF(CMAKE_D_USE_PHOBOS) +IF(CMAKE_D_BUILD_DOCS) + SET(DDOC_FLAGS "-fdoc -fdoc-dir=documentation") + FOREACH(item ${CMAKE_D_DDOC_FILES}) + SET(DDOC_FLAGS "${DDOC_FLAGS} -fdoc-inc=${item}") + ENDFOREACH(item) +ENDIF(CMAKE_D_BUILD_DOCS) + +SET (CMAKE_D_FLAGS_INIT "-fversion=Posix ${DSTDLIB_FLAGS}") +SET (CMAKE_D_FLAGS_DEBUG_INIT "-g ${DDOC_FLAGS}") +SET (CMAKE_D_FLAGS_MINSIZEREL_INIT "-Os ${DDOC_FLAGS}") +SET (CMAKE_D_FLAGS_RELEASE_INIT "-O3 -fomit-frame-pointer -fweb -frelease -finline-functions ${DDOC_FLAGS}") +SET (CMAKE_D_FLAGS_RELWITHDEBINFO_INIT "-O2 -g ${DDOC_FLAGS}") +# SET (CMAKE_D_CREATE_PREPROCESSED_SOURCE " -E > ") +SET (CMAKE_D_CREATE_ASSEMBLY_SOURCE " -S -o ") +#SET (CMAKE_INCLUDE_SYSTEM_FLAG_D "-isystem ") + diff --git a/cmake/Modules/Platform/Windows-dmd.cmake b/cmake/Modules/Platform/Windows-dmd.cmake new file mode 100644 index 0000000..f87e778 --- /dev/null +++ b/cmake/Modules/Platform/Windows-dmd.cmake @@ -0,0 +1,36 @@ +# +# CMakeD - CMake module for D Language +# +# Copyright (c) 2007, Selman Ulug +# Tim Burrell +# +# All rights reserved. +# +# See Copyright.txt for details. +# +# Modified from CMake 2.6.5 gcc.cmake +# See http://www.cmake.org/HTML/Copyright.html for details +# + +IF(CMAKE_D_USE_TANGO) + SET(DSTDLIB_FLAGS "-version=Tango") +ENDIF(CMAKE_D_USE_TANGO) +IF(CMAKE_D_USE_PHOBOS) + SET(DSTDLIB_FLAGS "-version=Phobos") +ENDIF(CMAKE_D_USE_PHOBOS) +IF(CMAKE_D_BUILD_DOCS) + SET(DDOC_FLAGS "-D -Dddocumentation") + #FOREACH(item ${CMAKE_D_DDOC_FILES}) + # SET(DDOC_FLAGS "${DDOC_FLAGS} ${item}") + #ENDFOREACH(item) +ENDIF(CMAKE_D_BUILD_DOCS) + +SET (CMAKE_D_FLAGS_INIT "-version=Win ${DSTDLIB_FLAGS}") +SET (CMAKE_D_FLAGS_DEBUG_INIT "-g ${DDOC_FLAGS}") +# SET (CMAKE_D_FLAGS_MINSIZEREL_INIT "-Os ${DDOC_FLAGS}") +SET (CMAKE_D_FLAGS_RELEASE_INIT "-O -release -inline ${DDOC_FLAGS}") +SET (CMAKE_D_FLAGS_RELWITHDEBINFO_INIT "-O -g ${DDOC_FLAGS}") +# SET (CMAKE_D_CREATE_PREPROCESSED_SOURCE " -E > ") +SET (CMAKE_D_CREATE_ASSEMBLY_SOURCE " -S -o ") +# SET (CMAKE_INCLUDE_SYSTEM_FLAG_D "-isystem ") + diff --git a/cmake/Modules/Platform/Windows-gdc.cmake b/cmake/Modules/Platform/Windows-gdc.cmake new file mode 100644 index 0000000..9b0cf81 --- /dev/null +++ b/cmake/Modules/Platform/Windows-gdc.cmake @@ -0,0 +1,36 @@ +# +# CMakeD - CMake module for D Language +# +# Copyright (c) 2007, Selman Ulug +# Tim Burrell +# +# All rights reserved. +# +# See Copyright.txt for details. +# +# Modified from CMake 2.6.5 gcc.cmake +# See http://www.cmake.org/HTML/Copyright.html for details +# + +IF(CMAKE_D_USE_TANGO) + SET(DSTDLIB_FLAGS "-fversion=Tango") +ENDIF(CMAKE_D_USE_TANGO) +IF(CMAKE_D_USE_PHOBOS) + SET(DSTDLIB_FLAGS "-fversion=Phobos") +ENDIF(CMAKE_D_USE_PHOBOS) +IF(CMAKE_D_BUILD_DOCS) + SET(DDOC_FLAGS "-fdoc -fdoc-dir=documentation") + FOREACH(item ${CMAKE_D_DDOC_FILES}) + SET(DDOC_FLAGS "${DDOC_FLAGS} -fdoc-inc=${item}") + ENDFOREACH(item) +ENDIF(CMAKE_D_BUILD_DOCS) + +SET (CMAKE_D_FLAGS_INIT "-fversion=Win ${DSTDLIB_FLAGS}") +SET (CMAKE_D_FLAGS_DEBUG_INIT "-g ${DDOC_FLAGS}") +SET (CMAKE_D_FLAGS_MINSIZEREL_INIT "-Os ${DDOC_FLAGS}") +SET (CMAKE_D_FLAGS_RELEASE_INIT "-O3 -fomit-frame-pointer -fweb -frelease -finline-functions ${DDOC_FLAGS}") +SET (CMAKE_D_FLAGS_RELWITHDEBINFO_INIT "-O2 -g ${DDOC_FLAGS}") +# SET (CMAKE_D_CREATE_PREPROCESSED_SOURCE " -E > ") +SET (CMAKE_D_CREATE_ASSEMBLY_SOURCE " -S -o ") +#SET (CMAKE_INCLUDE_SYSTEM_FLAG_D "-isystem ") + diff --git a/cmake/Modules/UseDDoc.cmake b/cmake/Modules/UseDDoc.cmake new file mode 100644 index 0000000..f941660 --- /dev/null +++ b/cmake/Modules/UseDDoc.cmake @@ -0,0 +1,61 @@ +# check if the user wants to build ddocs +# +# Copyright (c) 2007 Tim Burrell +# +# All rights reserved. +# +# See Copyright.txt for details. +# + +# Do not build documentation by default +if (NOT CMAKE_D_BUILD_DOCS) + set(CMAKE_D_BUILD_DOCS False CACHE BOOLEAN TRUE FORCE) +else (NOT CMAKE_D_BUILD_DOCS) + # check for specified ddoc files + # default to the candydoc usual + set(CMAKE_D_BUILD_DOCS True CACHE BOOLEAN FALSE FORCE) + if (NOT CMAKE_D_DDOC_FILES) + set(CMAKE_D_DDOC_FILES "documentation/candydoc/candy.ddoc;documentation/candydoc/modules.ddoc" CACHE STRING FALSE FORCE) + else (NOT CMAKE_D_DDOC_FILES) + set(CMAKE_D_DDOC_FILES "${CMAKE_D_DDOC_FILES}" CACHE STRING FALSE FORCE) + endif (NOT CMAKE_D_DDOC_FILES) + + # copy the candydoc files + file(GLOB_RECURSE CANDY_DOC_FILES "${CMAKE_CURRENT_SOURCE_DIR}/candydoc/*") + foreach(item ${CANDY_DOC_FILES}) + string(REGEX REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" item ${item}) + configure_file(${item} ${CMAKE_CURRENT_BINARY_DIR}/documentation/${item} COPYONLY) + endforeach(item) + + # create modules.ddoc + file(GLOB_RECURSE sources "${CMAKE_CURRENT_SOURCE_DIR}/*.d") + set(first True) + foreach(item ${sources}) + # first make sure we're not config.d + string(REGEX MATCH "config\\.d" ignore ${item}) + if (NOT ${ignore} MATCHES "") + # fix up the output + string(REGEX REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" item ${item}) + string(REGEX REPLACE "\\.d" ".html" htmlFile ${item}) + string(REGEX REPLACE "^.*/" "" htmlFile ${htmlFile}) + string(REGEX REPLACE "\\.d" "" item ${item}) + string(REGEX REPLACE "/" "." item ${item}) + if (first) + set(modules "${item}") + set(first False) + set(CMAKE_D_DDOC_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/documentation/${htmlFile}" CACHE STRING FALSE FORCE) + else (first) + set(modules "${modules};${item}") + set(CMAKE_D_DDOC_CLEAN_FILES "${CMAKE_D_DDOC_CLEAN_FILES}" "${CMAKE_CURRENT_BINARY_DIR}/documentation/${htmlFile}" CACHE STRING FALSE FORCE) + endif (first) + endif (NOT ${ignore} MATCHES "") + endforeach(item) + + # create formatted modules string + set(modString "MODULES = \n") + foreach(item ${modules}) + set(modString "${modString}\t$(MODULE ${item})\n") + endforeach(item) + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/documentation/candydoc/modules.ddoc" ${modString}) +endif (NOT CMAKE_D_BUILD_DOCS) + diff --git a/cmake/XConfig.cmake b/cmake/Modules/XConfig.cmake similarity index 100% rename from cmake/XConfig.cmake rename to cmake/Modules/XConfig.cmake diff --git a/configure b/configure index b57cd59..41f62eb 100755 --- a/configure +++ b/configure @@ -19,7 +19,7 @@ find . -name CMakeLists.txt | while read file; do do_makefile $file; done builddir=.build-$(hostname)-$(gcc -dumpmachine)-$(gcc -dumpversion) rm -rf $builddir mkdir -p $builddir -ln -s $builddir build +rm -f build && ln -s $builddir build if test $# -eq 0; then cd $builddir && cmake -DWITH_NNTP=1 -DWITH_IDN=1 -DUSE_HCACHE=1 -DCMAKE_INSTALL_PREFIX=/usr .. -- 2.20.1