From f23eee98283e99db7b283b143aa517232c80b23d Mon Sep 17 00:00:00 2001 From: Steve King Date: Sun, 8 Aug 2010 21:35:18 -0700 Subject: [PATCH] First attempt to overhaul for D2 and cmake 2.8. --- cmaked/CMakeDCompiler.cmake.in | 43 +++-- cmaked/CMakeDInformation.cmake | 199 ++++++++++------------ cmaked/CMakeDetermineDCompiler.cmake | 141 ++++++++++------ cmaked/CMakeLists.txt | 2 + cmaked/CMakeTestDCompiler.cmake | 239 ++++++++------------------- cmaked/Platform/Linux-dmd.cmake | 40 ++++- 6 files changed, 293 insertions(+), 371 deletions(-) diff --git a/cmaked/CMakeDCompiler.cmake.in b/cmaked/CMakeDCompiler.cmake.in index 6d18e3a..487b022 100644 --- a/cmaked/CMakeDCompiler.cmake.in +++ b/cmaked/CMakeDCompiler.cmake.in @@ -1,21 +1,11 @@ -# -# 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_D_COMPILER_ID "@CMAKE_D_COMPILER_ID@") +SET(CMAKE_D_PLATFORM_ID "@CMAKE_D_PLATFORM_ID@") +@SET_MSVC_D_ARCHITECTURE_ID@ SET(CMAKE_AR "@CMAKE_AR@") SET(CMAKE_RANLIB "@CMAKE_RANLIB@") +SET(CMAKE_LINKER "@CMAKE_LINKER@") SET(CMAKE_COMPILER_IS_GDC @CMAKE_COMPILER_IS_GDC@) SET(CMAKE_COMPILER_IS_DMD @CMAKE_COMPILER_IS_DMD@) SET(CMAKE_D_COMPILER_LOADED 1) @@ -35,11 +25,20 @@ 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@) +# Save compiler ABI information. +SET(CMAKE_D_SIZEOF_DATA_PTR "@CMAKE_D_SIZEOF_DATA_PTR@") +SET(CMAKE_D_COMPILER_ABI "@CMAKE_D_COMPILER_ABI@") + +IF(CMAKE_D_SIZEOF_DATA_PTR) + SET(CMAKE_SIZEOF_VOID_P "${CMAKE_D_SIZEOF_DATA_PTR}") +ENDIF(CMAKE_D_SIZEOF_DATA_PTR) + +IF(CMAKE_D_COMPILER_ABI) + SET(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_D_COMPILER_ABI}") +ENDIF(CMAKE_D_COMPILER_ABI) + +SET(CMAKE_D_HAS_ISYSROOT "@CMAKE_D_HAS_ISYSROOT@") +@CMAKE_D_OSX_DEPLOYMENT_TARGET_FLAG_CODE@ + +SET(CMAKE_D_IMPLICIT_LINK_LIBRARIES "@CMAKE_D_IMPLICIT_LINK_LIBRARIES@") +SET(CMAKE_D_IMPLICIT_LINK_DIRECTORIES "@CMAKE_D_IMPLICIT_LINK_DIRECTORIES@") diff --git a/cmaked/CMakeDInformation.cmake b/cmaked/CMakeDInformation.cmake index 954b3e5..681486d 100644 --- a/cmaked/CMakeDInformation.cmake +++ b/cmaked/CMakeDInformation.cmake @@ -15,19 +15,65 @@ # 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. +# It also loads a system - compiler - processor (or target hardware) +# specific file, which is mainly useful for crosscompiling and embedded systems. +# some compilers use different extensions (e.g. sdcc uses .rel) +# so set the extension here first so it can be overridden by the compiler specific file +IF(UNIX) + SET(CMAKE_D_OUTPUT_EXTENSION .o) +ELSE(UNIX) + SET(CMAKE_D_OUTPUT_EXTENSION .obj) +ENDIF(UNIX) + +# Load compiler-specific information. +IF(CMAKE_D_COMPILER_ID) + INCLUDE(Compiler/${CMAKE_D_COMPILER_ID}-D OPTIONAL) +ENDIF(CMAKE_D_COMPILER_ID) + +SET(CMAKE_BASE_NAME) GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_D_COMPILER} NAME_WE) +# This will need updating for the LLVM based ldc IF(CMAKE_COMPILER_IS_GDC) + SET(CMAKE_D_OUTPUT_NAME_SWITCH "-o") SET(CMAKE_BASE_NAME gdc) ELSE(CMAKE_COMPILER_IS_GDC) + SET(CMAKE_D_OUTPUT_NAME_SWITCH "-of") 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) + + +# load a hardware specific file, mostly useful for embedded compilers +IF(CMAKE_SYSTEM_PROCESSOR) + IF(CMAKE_D_COMPILER_ID) + INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_D_COMPILER_ID}-D-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) + ENDIF(CMAKE_D_COMPILER_ID) + IF (NOT _INCLUDED_FILE) + INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}-${CMAKE_SYSTEM_PROCESSOR} OPTIONAL) + ENDIF (NOT _INCLUDED_FILE) +ENDIF(CMAKE_SYSTEM_PROCESSOR) + + +# load the system- and compiler specific files +IF(CMAKE_D_COMPILER_ID) + INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_D_COMPILER_ID}-D + OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) +ENDIF(CMAKE_D_COMPILER_ID) +IF (NOT _INCLUDED_FILE) + INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} + OPTIONAL RESULT_VARIABLE _INCLUDED_FILE) +ENDIF (NOT _INCLUDED_FILE) +# We specify the compiler information in the system file for some +# platforms, but this language may not have been enabled when the file +# was first included. Include it again to get the language info. +# Remove this when all compiler info is removed from system files. +IF (NOT _INCLUDED_FILE) + INCLUDE(Platform/${CMAKE_SYSTEM_NAME} OPTIONAL) +ENDIF (NOT _INCLUDED_FILE) + # This should be included before the _INIT variables are -# used to initialize the cache. Since the rule variables +# 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. @@ -48,13 +94,18 @@ IF(NOT CMAKE_MODULE_EXISTS) 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.") +SET(CMAKE_D_FLAGS_INIT "$ENV{DFLAGS} ${CMAKE_D_FLAGS_INIT}") +# avoid just having a space as the initial value for the cache +IF(CMAKE_D_FLAGS_INIT STREQUAL " ") + SET(CMAKE_D_FLAGS_INIT) +ENDIF(CMAKE_D_FLAGS_INIT STREQUAL " ") +SET (CMAKE_D_FLAGS "${CMAKE_D_FLAGS_INIT}" CACHE STRING + "Flags used by the D compiler during all build types.") 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 + 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 @@ -69,7 +120,7 @@ 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.") + CACHE STRING "Libraries linked by default with all D applications.") MARK_AS_ADVANCED(CMAKE_D_STANDARD_LIBRARIES) ENDIF(CMAKE_D_STANDARD_LIBRARIES_INIT) @@ -93,84 +144,20 @@ INCLUDE(CMakeCommonLanguageInclude) # # 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) + SET(CMAKE_D_CREATE_SHARED_LIBRARY + " ${CMAKE_D_OUTPUT_NAME_SWITCH} ${DSTDLIB_FLAGS} ${CMAKE_D_STDLIBS}") ENDIF(NOT CMAKE_D_CREATE_SHARED_LIBRARY) # create a D shared module just copy the shared library rule @@ -178,55 +165,35 @@ 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) +# Create a static archive incrementally for large object file counts. +# If CMAKE_D_CREATE_STATIC_LIBRARY is set it will override these. +SET(CMAKE_D_ARCHIVE_CREATE " cr ") +SET(CMAKE_D_ARCHIVE_APPEND " r ") +SET(CMAKE_D_ARCHIVE_FINISH " ") # compile a D file into an object file IF(NOT CMAKE_D_COMPILE_OBJECT) SET(CMAKE_D_COMPILE_OBJECT - " ${CMAKE_OUTPUT_D_FLAG} -c ") + " ${CMAKE_D_OUTPUT_NAME_SWITCH} -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) + SET(CMAKE_D_LINK_EXECUTABLE + "gcc -o ${CMAKE_D_STDLIBS}") ENDIF(NOT CMAKE_D_LINK_EXECUTABLE) +IF(NOT CMAKE_EXECUTABLE_RUNTIME_D_FLAG) + SET(CMAKE_EXECUTABLE_RUNTIME_D_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_D_FLAG}) +ENDIF(NOT CMAKE_EXECUTABLE_RUNTIME_D_FLAG) + +IF(NOT CMAKE_EXECUTABLE_RUNTIME_D_FLAG_SEP) + SET(CMAKE_EXECUTABLE_RUNTIME_D_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_D_FLAG_SEP}) +ENDIF(NOT CMAKE_EXECUTABLE_RUNTIME_D_FLAG_SEP) + +IF(NOT CMAKE_EXECUTABLE_RPATH_LINK_D_FLAG) + SET(CMAKE_EXECUTABLE_RPATH_LINK_D_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_D_FLAG}) +ENDIF(NOT CMAKE_EXECUTABLE_RPATH_LINK_D_FLAG) + MARK_AS_ADVANCED( CMAKE_D_FLAGS CMAKE_D_FLAGS_DEBUG diff --git a/cmaked/CMakeDetermineDCompiler.cmake b/cmaked/CMakeDetermineDCompiler.cmake index 1655dbf..621d5d3 100644 --- a/cmaked/CMakeDetermineDCompiler.cmake +++ b/cmaked/CMakeDetermineDCompiler.cmake @@ -15,26 +15,25 @@ # 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 +# 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) - + SET(CMAKE_D_COMPILER_INIT NOTFOUND) # 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}) + IF(NOT EXISTS ${CMAKE_D_COMPILER_INIT}) + MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable C:\n$ENV{DC}.") + ENDIF(NOT EXISTS ${CMAKE_D_COMPILER_INIT}) ENDIF($ENV{DC} MATCHES ".+") # next try prefer the compiler specified by the generator - IF(CMAKE_GENERATOR_D) + IF(CMAKE_GENERATOR_D) IF(NOT CMAKE_D_COMPILER_INIT) SET(CMAKE_D_COMPILER_INIT ${CMAKE_GENERATOR_D}) ENDIF(NOT CMAKE_D_COMPILER_INIT) @@ -44,65 +43,101 @@ IF(NOT CMAKE_D_COMPILER) 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) + SET(CMAKE_D_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}gdc ${_CMAKE_TOOLCHAIN_PREFIX}dmd) ENDIF(CMAKE_D_COMPILER_INIT) # Find the compiler. - FIND_PROGRAM(CMAKE_D_COMPILER NAMES ${CMAKE_D_COMPILER_LIST} DOC "C compiler") + IF (_CMAKE_USER_D_COMPILER_PATH) + FIND_PROGRAM(CMAKE_D_COMPILER NAMES ${CMAKE_D_COMPILER_LIST} PATHS ${_CMAKE_USER_D_COMPILER_PATH} DOC "D compiler" NO_DEFAULT_PATH) + ENDIF (_CMAKE_USER_D_COMPILER_PATH) + FIND_PROGRAM(CMAKE_D_COMPILER NAMES ${CMAKE_D_COMPILER_LIST} DOC "D compiler") + IF(CMAKE_D_COMPILER_INIT AND NOT CMAKE_D_COMPILER) - SET(CMAKE_D_COMPILER "${CMAKE_D_COMPILER_INIT}" CACHE FILEPATH "C compiler" FORCE) + SET(CMAKE_D_COMPILER "${CMAKE_D_COMPILER_INIT}" CACHE FILEPATH "D compiler" FORCE) ENDIF(CMAKE_D_COMPILER_INIT AND NOT CMAKE_D_COMPILER) +ELSE (NOT CMAKE_D_COMPILER) + + # we only get here if CMAKE_D_COMPILER was specified using -D or a pre-made CMakeCache.txt + # (e.g. via ctest) or set in CMAKE_TOOLCHAIN_FILE + # if CMAKE_D_COMPILER is a list of length 2, use the first item as + # CMAKE_D_COMPILER and the 2nd one as CMAKE_D_COMPILER_ARG1 + + LIST(LENGTH CMAKE_D_COMPILER _CMAKE_D_COMPILER_LIST_LENGTH) + IF("${_CMAKE_D_COMPILER_LIST_LENGTH}" EQUAL 2) + LIST(GET CMAKE_D_COMPILER 1 CMAKE_D_COMPILER_ARG1) + LIST(GET CMAKE_D_COMPILER 0 CMAKE_D_COMPILER) + ENDIF("${_CMAKE_D_COMPILER_LIST_LENGTH}" EQUAL 2) + + # if a compiler was specified by the user but without path, + # now try to find it with the full path + # if it is found, force it into the cache, + # if not, don't overwrite the setting (which was given by the user) with "NOTFOUND" + # if the C compiler already had a path, reuse it for searching the CXX compiler + GET_FILENAME_COMPONENT(_CMAKE_USER_D_COMPILER_PATH "${CMAKE_D_COMPILER}" PATH) + IF(NOT _CMAKE_USER_D_COMPILER_PATH) + FIND_PROGRAM(CMAKE_D_COMPILER_WITH_PATH NAMES ${CMAKE_D_COMPILER}) + MARK_AS_ADVANCED(CMAKE_D_COMPILER_WITH_PATH) + IF(CMAKE_D_COMPILER_WITH_PATH) + SET(CMAKE_D_COMPILER ${CMAKE_D_COMPILER_WITH_PATH} CACHE STRING "D compiler" FORCE) + ENDIF(CMAKE_D_COMPILER_WITH_PATH) + ENDIF(NOT _CMAKE_USER_D_COMPILER_PATH) ENDIF(NOT CMAKE_D_COMPILER) -MARK_AS_ADVANCED(CMAKE_D_COMPILER) -GET_FILENAME_COMPONENT(COMPILER_LOCATION "${CMAKE_D_COMPILER}" PATH) +MARK_AS_ADVANCED(CMAKE_D_COMPILER) -FIND_PROGRAM(CMAKE_AR NAMES ar PATHS ${COMPILER_LOCATION} ) +IF (NOT _CMAKE_TOOLCHAIN_LOCATION) + GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_D_COMPILER}" PATH) +ENDIF (NOT _CMAKE_TOOLCHAIN_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 +# Build a small source file to identify the compiler. IF(${CMAKE_GENERATOR} MATCHES "Visual Studio") - SET(CMAKE_COMPILER_IS_GDC_RUN 1) -ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio") + SET(CMAKE_D_COMPILER_ID_RUN 1) + SET(CMAKE_D_PLATFORM_ID "Windows") + # TODO: Set the compiler id. It is probably MSVC but + # the user may be using an integrated Intel compiler. + # SET(CMAKE_D_COMPILER_ID "MSVC") +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.*" ) +IF(NOT CMAKE_D_COMPILER_ID_RUN) + SET(CMAKE_D_COMPILER_ID_RUN 1) + + # Each entry in this list is a set of extra flags to try + # adding to the compile line to see if it helps produce + # a valid identification file. + SET(CMAKE_D_COMPILER_ID_TEST_FLAGS + # Try compiling to an object file only. + "-c" + ) + + # Try to identify the compiler. + SET(CMAKE_D_COMPILER_ID) + FILE(READ ${CMAKE_ROOT}/Modules/CMakePlatformId.h.in + CMAKE_D_COMPILER_ID_PLATFORM_CONTENT) + INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) + CMAKE_DETERMINE_COMPILER_ID(D DFLAGS CMakeDCompilerId.d) + + # Set old compiler and platform id variables. + IF("${CMAKE_D_COMPILER_ID}" MATCHES "GNU") 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) + ENDIF("${CMAKE_D_COMPILER_ID}" MATCHES "GNU") + IF("${CMAKE_D_PLATFORM_ID}" MATCHES "MinGW") + SET(CMAKE_COMPILER_IS_MINGW 1) + ELSEIF("${CMAKE_D_PLATFORM_ID}" MATCHES "Cygwin") + SET(CMAKE_COMPILER_IS_CYGWIN 1) + ENDIF("${CMAKE_D_PLATFORM_ID}" MATCHES "MinGW") +ENDIF(NOT CMAKE_D_COMPILER_ID_RUN) + + +INCLUDE(CMakeFindBinUtils) +IF(MSVC_D_ARCHITECTURE_ID) + SET(SET_MSVC_D_ARCHITECTURE_ID + "SET(MSVC_D_ARCHITECTURE_ID ${MSVC_D_ARCHITECTURE_ID})") +ENDIF(MSVC_D_ARCHITECTURE_ID) # 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) +CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeDCompiler.cmake.in + "${CMAKE_PLATFORM_ROOT_BIN}/CMakeDCompiler.cmake" + @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 + ) SET(CMAKE_D_COMPILER_ENV_VAR "DC") - diff --git a/cmaked/CMakeLists.txt b/cmaked/CMakeLists.txt index 6e73d63..23d2d46 100644 --- a/cmaked/CMakeLists.txt +++ b/cmaked/CMakeLists.txt @@ -15,7 +15,9 @@ PROJECT (cmaked NONE) # to build the samples, and can break apps that use other FindGTK2 modules. SET (MOD_SRCS CMakeDCompiler.cmake.in + CMakeDCompilerId.d.in CMakeDInformation.cmake + CMakeDCompilerABI.d CMakeTestDCompiler.cmake CMakeDetermineDCompiler.cmake FindGDCPath.cmake diff --git a/cmaked/CMakeTestDCompiler.cmake b/cmaked/CMakeTestDCompiler.cmake index 4fb7c7c..b2315f8 100644 --- a/cmaked/CMakeTestDCompiler.cmake +++ b/cmaked/CMakeTestDCompiler.cmake @@ -1,175 +1,72 @@ -# -# 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) +# +# 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 +# -# 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) +INCLUDE(CMakeTestCompilerCommon) -# 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) +# 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) + PrintTestCompilerStatus("D" "") + FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testDCompiler.d + "int main(char[][] args)\n" + "{return args.sizeof-1;}\n") + TRY_COMPILE(CMAKE_D_COMPILER_WORKS ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testDCompiler.d + OUTPUT_VARIABLE OUTPUT) + SET(D_TEST_WAS_RUN 1) +ENDIF(NOT CMAKE_D_COMPILER_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) +IF(NOT CMAKE_D_COMPILER_WORKS) + PrintTestCompilerStatus("D" " -- broken") + message(STATUS "To force a specific D compiler set the DC environment variable") + message(STATUS " ie - export DC=\"/usr/bin/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") + # if the compiler is broken make sure to remove the platform file + # since Windows-cl configures both c/cxx files both need to be removed + # when c or c++ fails + FILE(REMOVE ${CMAKE_PLATFORM_ROOT_BIN}/CMakeDPlatform.cmake ) + 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(D_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(D_TEST_WAS_RUN) + SET(CMAKE_D_COMPILER_WORKS 1 CACHE INTERNAL "") + + IF(CMAKE_D_COMPILER_FORCED) + # The compiler configuration was forced by the user. + # Assume the user has configured all compiler information. + ELSE(CMAKE_D_COMPILER_FORCED) + # Try to identify the ABI and configure it into CMakeDCompiler.cmake + INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake) + CMAKE_DETERMINE_COMPILER_ABI(D ${CMAKE_ROOT}/Modules/CMakeDCompilerABI.d) + CONFIGURE_FILE( + ${CMAKE_ROOT}/Modules/CMakeDCompiler.cmake.in + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeDCompiler.cmake + @ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0 + ) + INCLUDE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeDCompiler.cmake) + ENDIF(CMAKE_D_COMPILER_FORCED) +ENDIF(NOT CMAKE_D_COMPILER_WORKS) diff --git a/cmaked/Platform/Linux-dmd.cmake b/cmaked/Platform/Linux-dmd.cmake index 7136a37..a992f41 100644 --- a/cmaked/Platform/Linux-dmd.cmake +++ b/cmaked/Platform/Linux-dmd.cmake @@ -12,12 +12,7 @@ # 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) +SET(DSTDLIB_FLAGS "-version=Phobos") IF(CMAKE_D_BUILD_DOCS) SET(DDOC_FLAGS "-D -Dddocumentation") #FOREACH(item ${CMAKE_D_DDOC_FILES}) @@ -25,11 +20,38 @@ IF(CMAKE_D_BUILD_DOCS) #ENDFOREACH(item) ENDIF(CMAKE_D_BUILD_DOCS) -SET (CMAKE_D_FLAGS_INIT "-version=${CMAKE_BUILD_TYPE}Build ${DSTDLIB_FLAGS} ${DSTDLIB_TYPE} -I$ENV{D_PATH}/include -I$ENV{D_PATH}/import -I${CMAKE_PROJECT_SOURCE_DIR}") -SET (CMAKE_D_FLAGS_DEBUG_INIT "-g ${DDOC_FLAGS}") +SET(CMAKE_SHARED_LIBRARY_D_FLAGS "") # -pic +SET(CMAKE_SHARED_LIBRARY_CREATE_D_FLAGS "-shared") # -shared +SET(CMAKE_SHARED_LIBRARY_LINK_D_FLAGS "") # +s, flag for exe link to use shared lib +SET(CMAKE_SHARED_LIBRARY_RUNTIME_D_FLAG "") # -rpath +SET(CMAKE_SHARED_LIBRARY_RUNTIME_D_FLAG_SEP "") # : or empty +SET(CMAKE_INCLUDE_FLAG_D "-I") # -I +SET(CMAKE_INCLUDE_FLAG_D_SEP "") # , or empty +SET(CMAKE_LIBRARY_PATH_FLAG "-L") +SET(CMAKE_LIBRARY_PATH_TERMINATOR "") # for the Digital Mars D compiler the link paths have to be terminated with a "/" +SET(CMAKE_LINK_LIBRARY_FLAG "-l") + +SET(CMAKE_LINK_LIBRARY_SUFFIX "") +SET(CMAKE_STATIC_LIBRARY_PREFIX "lib") +SET(CMAKE_STATIC_LIBRARY_SUFFIX ".a") +SET(CMAKE_SHARED_LIBRARY_PREFIX "lib") # lib +SET(CMAKE_SHARED_LIBRARY_SUFFIX ".so") # .so +SET(CMAKE_EXECUTABLE_SUFFIX "") # .exe +SET(CMAKE_DL_LIBS "dl") + +SET(CMAKE_FIND_LIBRARY_PREFIXES "lib") +SET(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a") + +SET(CMAKE_D_STDLIBS "-lphobos2 -lpthread -lm" ) + +#SET (CMAKE_D_FLAGS_INIT "-version=${CMAKE_BUILD_TYPE}Build ${DSTDLIB_FLAGS} ${DSTDLIB_TYPE} -I$ENV{D_PATH}/include -I$ENV{D_PATH}/import -I${CMAKE_PROJECT_SOURCE_DIR}") +SET (CMAKE_D_FLAGS_INIT "") +# DMD can only produce 32-bit binaries for now +SET (CMAKE_D_LINK_FLAGS "") +SET (CMAKE_D_FLAGS_DEBUG_INIT "-g -debug -L--export-dynamic ${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_D_CREATE_ASSEMBLY_SOURCE " -S -of") # SET (CMAKE_INCLUDE_SYSTEM_FLAG_D "-isystem ")