Renamed project
This commit is contained in:
parent
73110c9406
commit
61468c2e79
21 changed files with 7 additions and 7 deletions
46
cmake-d/CMakeDCompiler.cmake.in
Normal file
46
cmake-d/CMakeDCompiler.cmake.in
Normal file
|
@ -0,0 +1,46 @@
|
|||
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)
|
||||
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_D_SOURCE_FILE_EXTENSIONS d;di)
|
||||
SET(CMAKE_D_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
|
||||
# Prefer to use D's linker.
|
||||
# The D value 40 beats CXX value of 30 and C value of 10
|
||||
SET(CMAKE_D_LINKER_PREFERENCE 40 )
|
||||
SET(CMAKE_D_LINKER_PREFERENCE_PROPOGATES 1 )
|
||||
# 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@")
|
5
cmake-d/CMakeDCompilerABI.d
Normal file
5
cmake-d/CMakeDCompilerABI.d
Normal file
|
@ -0,0 +1,5 @@
|
|||
int main( string[] args )
|
||||
{
|
||||
int require = 0;
|
||||
return require;
|
||||
}
|
39
cmake-d/CMakeDCompilerId.d.in
Normal file
39
cmake-d/CMakeDCompilerId.d.in
Normal file
|
@ -0,0 +1,39 @@
|
|||
version(DigitalMars)
|
||||
{
|
||||
const string COMPILER_ID = "DigitalMars";
|
||||
}
|
||||
else version(GNU)
|
||||
{
|
||||
const string COMPILER_ID = "GNU";
|
||||
}
|
||||
else version(LDC)
|
||||
{
|
||||
const string COMPILER_ID = "LDC";
|
||||
}
|
||||
else version(SDC)
|
||||
{
|
||||
const string COMPILER_ID = "SDC";
|
||||
}
|
||||
else
|
||||
{
|
||||
const string COMPILER_ID = "";
|
||||
}
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
string info_compiler = "INFO" ":" "compiler[" ~ COMPILER_ID ~ "]";
|
||||
|
||||
@CMAKE_D_COMPILER_ID_PLATFORM_CONTENT@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
int main(string[] args)
|
||||
{
|
||||
int require = 0;
|
||||
require += info_compiler[args.length];
|
||||
require += info_platform[args.length];
|
||||
require += info_arch[args.length];
|
||||
return require;
|
||||
}
|
205
cmake-d/CMakeDInformation.cmake
Normal file
205
cmake-d/CMakeDInformation.cmake
Normal file
|
@ -0,0 +1,205 @@
|
|||
#
|
||||
# CMakeD - CMake module for D Language
|
||||
#
|
||||
# Copyright (c) 2007, Selman Ulug <selman.ulug@gmail.com>
|
||||
# Tim Burrell <tim.burrell@gmail.com>
|
||||
# Steve King <sk@metrokings.com>
|
||||
#
|
||||
# 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.
|
||||
# It also loads a system - compiler - processor (or target hardware)
|
||||
# specific file, which is mainly useful for crosscompiling and embedded systems.
|
||||
|
||||
# Load compiler-specific information.
|
||||
|
||||
SET( _INCLUDED_FILE 0 ) # reset the indicator if an include occurred.
|
||||
|
||||
IF(CMAKE_D_COMPILER_ID)
|
||||
INCLUDE(Compiler/${CMAKE_D_COMPILER_ID}-D OPTIONAL)
|
||||
ENDIF(CMAKE_D_COMPILER_ID)
|
||||
|
||||
# SET(CMAKE_D_OUTPUT_EXTENSION .o)
|
||||
SET(CMAKE_C_OUTPUT_EXTENSION_REPLACE TRUE )
|
||||
SET(CMAKE_D_OUTPUT_EXTENSION_REPLACE TRUE )
|
||||
|
||||
SET(CMAKE_BASE_NAME)
|
||||
GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_D_COMPILER} NAME_WE)
|
||||
|
||||
SET( _INCLUDED_FILE 0 ) # reset the indicator if an include occurred.
|
||||
|
||||
# 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)
|
||||
|
||||
SET( _INCLUDED_FILE 0 ) # reset the indicator if an include occurred.
|
||||
|
||||
# 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 no high specificity file was included, then try a more general one
|
||||
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
|
||||
# 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_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
|
||||
"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 default 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
|
||||
# <TARGET>
|
||||
# <TARGET_BASE> the target without the suffix
|
||||
# <OBJECTS>
|
||||
# <OBJECT>
|
||||
# <LINK_LIBRARIES>
|
||||
# <FLAGS>
|
||||
# <LINK_FLAGS>
|
||||
|
||||
# D compiler information
|
||||
# <CMAKE_D_COMPILER>
|
||||
# <CMAKE_SHARED_LIBRARY_CREATE_D_FLAGS>
|
||||
# <CMAKE_SHARED_MODULE_CREATE_D_FLAGS>
|
||||
# <CMAKE_D_LINK_FLAGS>
|
||||
|
||||
# Static library tools
|
||||
# <CMAKE_AR>
|
||||
# <CMAKE_RANLIB>
|
||||
|
||||
|
||||
# create a D shared library
|
||||
IF(NOT CMAKE_D_CREATE_SHARED_LIBRARY)
|
||||
SET(CMAKE_D_CREATE_SHARED_LIBRARY
|
||||
"<CMAKE_D_COMPILER> <CMAKE_SHARED_LIBRARY_D_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_D_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_D_FLAG><TARGET_SONAME> ${CMAKE_D_DASH_O}<TARGET> <OBJECTS> <LINK_LIBRARIES> ${DSTDLIB_FLAGS} ${CMAKE_D_STDLIBS}")
|
||||
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)
|
||||
IF(NOT CMAKE_D_CREATE_STATIC_LIBRARY AND CMAKE_STATIC_LIBRARY_CREATE_D_FLAGS)
|
||||
SET(CMAKE_D_CREATE_STATIC_LIBRARY
|
||||
"<CMAKE_D_COMPILER> ${CMAKE_STATIC_LIBRARY_CREATE_D_FLAGS} <OBJECTS> ${CMAKE_D_DASH_O}<TARGET>")
|
||||
ENDIF(NOT CMAKE_D_CREATE_STATIC_LIBRARY AND CMAKE_STATIC_LIBRARY_CREATE_D_FLAGS)
|
||||
|
||||
# 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 "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||
SET(CMAKE_D_ARCHIVE_APPEND "<CMAKE_AR> r <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||
SET(CMAKE_D_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
|
||||
|
||||
# compile a D file into an object file
|
||||
IF(NOT CMAKE_D_COMPILE_OBJECT)
|
||||
SET(CMAKE_D_COMPILE_OBJECT
|
||||
"<CMAKE_D_COMPILER> <FLAGS> ${CMAKE_D_DASH_O}<OBJECT> -c <SOURCE>")
|
||||
ENDIF(NOT CMAKE_D_COMPILE_OBJECT)
|
||||
|
||||
IF(NOT CMAKE_D_LINK_EXECUTABLE)
|
||||
SET(CMAKE_D_LINK_EXECUTABLE
|
||||
"<CMAKE_D_COMPILER> <FLAGS> <CMAKE_D_LINK_FLAGS> <OBJECTS> ${CMAKE_D_DASH_O}<TARGET> <LINK_LIBRARIES> ${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
|
||||
CMAKE_D_FLAGS_MINSIZEREL
|
||||
CMAKE_D_FLAGS_RELEASE
|
||||
CMAKE_D_FLAGS_RELWITHDEBINFO
|
||||
)
|
||||
SET(CMAKE_D_INFORMATION_LOADED 1)
|
149
cmake-d/CMakeDetermineDCompiler.cmake
Normal file
149
cmake-d/CMakeDetermineDCompiler.cmake
Normal file
|
@ -0,0 +1,149 @@
|
|||
#
|
||||
# CMakeD - CMake module for D Language
|
||||
#
|
||||
# Copyright (c) 2007, Selman Ulug <selman.ulug@gmail.com>
|
||||
# Tim Burrell <tim.burrell@gmail.com>
|
||||
#
|
||||
# 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)
|
||||
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(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(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 ${_CMAKE_TOOLCHAIN_PREFIX}gdc ${_CMAKE_TOOLCHAIN_PREFIX}dmd)
|
||||
ENDIF(CMAKE_D_COMPILER_INIT)
|
||||
|
||||
# Find the 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 "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)
|
||||
|
||||
IF (NOT _CMAKE_TOOLCHAIN_LOCATION)
|
||||
GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_D_COMPILER}" PATH)
|
||||
ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION)
|
||||
|
||||
# Build a small source file to identify the compiler.
|
||||
IF(${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_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)
|
||||
FIND_FILE(CMAKE_PLATFORM_ID_CONTENT_FILE CMakePlatformId.di.in
|
||||
PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH})
|
||||
FILE(READ ${CMAKE_PLATFORM_ID_CONTENT_FILE} CMAKE_D_COMPILER_ID_PLATFORM_CONTENT)
|
||||
INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
|
||||
# Workaround for bug http://public.kitware.com/Bug/view.php?id=14481
|
||||
FIND_FILE(CMAKE_D_COMPILER_ID_FILE_IN CMakeDCompilerId.d.in PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH})
|
||||
FILE(RELATIVE_PATH CMAKE_D_COMPILER_ID_FILE_IN_RELATIVE ${CMAKE_ROOT}/Modules ${CMAKE_D_COMPILER_ID_FILE_IN})
|
||||
STRING(REGEX REPLACE "[.]in$" "" CMAKE_COMPILER_ID_FILE_RELATIVE ${CMAKE_D_COMPILER_ID_FILE_IN_RELATIVE})
|
||||
CMAKE_DETERMINE_COMPILER_ID(D DFLAGS ${CMAKE_COMPILER_ID_FILE_RELATIVE})
|
||||
UNSET(CMAKE_D_COMPILER_ID_FILE_IN CACHE)
|
||||
UNSET(CMAKE_PLATFORM_ID_CONTENT_FILE CACHE)
|
||||
|
||||
# Set old compiler and platform id variables.
|
||||
IF("${CMAKE_D_COMPILER_ID}" MATCHES "GNU")
|
||||
SET(CMAKE_COMPILER_IS_GDC 1)
|
||||
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
|
||||
FIND_FILE(CMAKE_D_COMPILER_CMAKE_IN CMakeDCompiler.cmake.in
|
||||
PATHS ${CMAKE_ROOT} ${CMAKE_MODULE_PATH})
|
||||
CONFIGURE_FILE(${CMAKE_D_COMPILER_CMAKE_IN}
|
||||
${CMAKE_PLATFORM_INFO_DIR}/CMakeDCompiler.cmake
|
||||
@ONLY IMMEDIATE # IMMEDIATE must be here for compatibility mode <= 2.0
|
||||
)
|
||||
SET(CMAKE_D_COMPILER_ENV_VAR "DC")
|
37
cmake-d/CMakeLists.txt
Normal file
37
cmake-d/CMakeLists.txt
Normal file
|
@ -0,0 +1,37 @@
|
|||
#
|
||||
# CMakeD - CMake module for D Language
|
||||
#
|
||||
# Copyright (c) 2007, Selman Ulug <selman.ulug@gmail.com>
|
||||
# Tim Burrell <tim.burrell@gmail.com>
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# See Copyright.txt for details.
|
||||
#
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.1)
|
||||
PROJECT (cmake-d NONE)
|
||||
|
||||
SET (MOD_SRCS
|
||||
CMakeDCompiler.cmake.in
|
||||
CMakeDCompilerId.d.in
|
||||
CMakeDInformation.cmake
|
||||
CMakeDCompilerABI.d
|
||||
CMakeTestDCompiler.cmake
|
||||
CMakeDetermineDCompiler.cmake
|
||||
FindGDCPath.cmake
|
||||
UseDDoc.cmake
|
||||
UseDDeps.cmake
|
||||
dependencies.cmake
|
||||
UseDUnittest.cmake
|
||||
FindPhobos.cmake
|
||||
)
|
||||
|
||||
SET (PLAT_SRCS
|
||||
Platform/Linux-dmd.cmake
|
||||
Platform/Linux-gdc.cmake
|
||||
Platform/Windows-dmd.cmake
|
||||
Platform/Windows-gdc.cmake
|
||||
)
|
||||
|
||||
INSTALL (FILES ${MOD_SRCS} DESTINATION ${CMAKE_ROOT}/Modules)
|
||||
INSTALL (FILES ${PLAT_SRCS} DESTINATION ${CMAKE_ROOT}/Modules/Platform)
|
118
cmake-d/CMakePlatformId.di.in
Normal file
118
cmake-d/CMakePlatformId.di.in
Normal file
|
@ -0,0 +1,118 @@
|
|||
/* Identify known platforms by name. */
|
||||
version(linux)
|
||||
{
|
||||
const string PLATFORM_ID = "Linux";
|
||||
}
|
||||
else version(Cygwin)
|
||||
{
|
||||
const string PLATFORM_ID = "Cygwin";
|
||||
}
|
||||
else version(MinGW)
|
||||
{
|
||||
const string PLATFORM_ID = "MinGW";
|
||||
}
|
||||
else version(OSX)
|
||||
{
|
||||
const string PLATFORM_ID = "Darwin";
|
||||
}
|
||||
else version(Windows)
|
||||
{
|
||||
const string PLATFORM_ID = "Windows";
|
||||
}
|
||||
else version(FreeBSD)
|
||||
{
|
||||
const string PLATFORM_ID = "FreeBSD";
|
||||
}
|
||||
else version(NetBSD)
|
||||
{
|
||||
const string PLATFORM_ID = "NetBSD";
|
||||
}
|
||||
else version(OpenBSD)
|
||||
{
|
||||
const string PLATFORM_ID = "OpenBSD";
|
||||
}
|
||||
else version(NetBSD)
|
||||
{
|
||||
const string PLATFORM_ID = "NetBSD";
|
||||
}
|
||||
else version(Solaris)
|
||||
{
|
||||
const string PLATFORM_ID = "SunOS";
|
||||
}
|
||||
else version(AIX)
|
||||
{
|
||||
const string PLATFORM_ID = "AIX";
|
||||
}
|
||||
else version(Haiku)
|
||||
{
|
||||
const string PLATFORM_ID = "Haiku";
|
||||
}
|
||||
else version(AIX)
|
||||
{
|
||||
const string PLATFORM_ID = "BeOS";
|
||||
}
|
||||
else version(AIX)
|
||||
{
|
||||
const string PLATFORM_ID = "QNX";
|
||||
}
|
||||
else version(AIX)
|
||||
{
|
||||
const string PLATFORM_ID = "Tru64";
|
||||
}
|
||||
else version(AIX)
|
||||
{
|
||||
const string PLATFORM_ID = "RISCos";
|
||||
}
|
||||
else
|
||||
{
|
||||
const string PLATFORM_ID = "";
|
||||
}
|
||||
|
||||
/* For windows compilers MSVC and Intel we can determine
|
||||
the architecture of the compiler being used. This is because
|
||||
the compilers do not have flags that can change the architecture,
|
||||
but rather depend on which compiler is being used
|
||||
*/
|
||||
version(IA64)
|
||||
{
|
||||
const string ARCHITECTURE_ID = "IA64";
|
||||
}
|
||||
else version(X86_64)
|
||||
{
|
||||
const string ARCHITECTURE_ID = "x64";
|
||||
}
|
||||
else version(X86)
|
||||
{
|
||||
const string ARCHITECTURE_ID = "X86";
|
||||
}
|
||||
else version(ARM)
|
||||
{
|
||||
const string ARCHITECTURE_ID = "ARM";
|
||||
}
|
||||
else version(MIPS32)
|
||||
{
|
||||
const string ARCHITECTURE_ID = "MIPS";
|
||||
}
|
||||
else version(MIPS64)
|
||||
{
|
||||
const string ARCHITECTURE_ID = "MIPS";
|
||||
}
|
||||
else version(SH)
|
||||
{
|
||||
const string ARCHITECTURE_ID = "SHx";
|
||||
}
|
||||
else version(SH64)
|
||||
{
|
||||
const string ARCHITECTURE_ID = "SHx";
|
||||
}
|
||||
else
|
||||
{
|
||||
const string ARCHITECTURE_ID = "";
|
||||
}
|
||||
|
||||
/* Construct the string literal in pieces to prevent the source from
|
||||
getting matched. Store it in a pointer rather than an array
|
||||
because some compilers will just produce instructions to fill the
|
||||
array rather than assigning a pointer to a static array. */
|
||||
string info_platform = "INFO" ":" "platform[" ~ PLATFORM_ID ~ "]";
|
||||
string info_arch = "INFO" ":" "arch[" ~ ARCHITECTURE_ID ~"]";
|
77
cmake-d/CMakeTestDCompiler.cmake
Normal file
77
cmake-d/CMakeTestDCompiler.cmake
Normal file
|
@ -0,0 +1,77 @@
|
|||
#
|
||||
# CMakeD - CMake module for D Language
|
||||
#
|
||||
# Copyright (c) 2007, Selman Ulug <selman.ulug@gmail.com>
|
||||
# Tim Burrell <tim.burrell@gmail.com>
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
INCLUDE(CMakeTestCompilerCommon)
|
||||
|
||||
# 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(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)
|
||||
FIND_FILE(CMAKE_D_COMPILER_ABI_SRC CMakeDCompilerABI.d
|
||||
PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH})
|
||||
CMAKE_DETERMINE_COMPILER_ABI(D ${CMAKE_D_COMPILER_ABI_SRC})
|
||||
FIND_FILE(CMAKE_D_COMPILER_CMAKE_IN CMakeDCompiler.cmake.in
|
||||
PATHS ${CMAKE_ROOT}/Modules ${CMAKE_MODULE_PATH})
|
||||
CONFIGURE_FILE(
|
||||
${CMAKE_D_COMPILER_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)
|
||||
UNSET(CMAKE_D_COMPILER_ABI_SRC CACHE)
|
||||
UNSET(CMAKE_D_COMPILER_CMAKE_IN CACHE)
|
||||
ENDIF(CMAKE_D_COMPILER_FORCED)
|
||||
ENDIF(NOT CMAKE_D_COMPILER_WORKS)
|
30
cmake-d/Copyright.txt
Normal file
30
cmake-d/Copyright.txt
Normal file
|
@ -0,0 +1,30 @@
|
|||
CMakeD - CMake module for D Language
|
||||
|
||||
Copyright (c) 2007, Selman Ulug <selman.ulug@gmail.com>
|
||||
Tim Burrell <tim.burrell@gmail.com>
|
||||
|
||||
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.
|
43
cmake-d/FindGDCPath.cmake
Normal file
43
cmake-d/FindGDCPath.cmake
Normal file
|
@ -0,0 +1,43 @@
|
|||
#
|
||||
# CMakeD - CMake module for D Language
|
||||
#
|
||||
# Copyright (c) 2007, Selman Ulug <selman.ulug@gmail.com>
|
||||
# Tim Burrell <tim.burrell@gmail.com>
|
||||
#
|
||||
# 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
|
||||
)
|
5
cmake-d/FindPhobos.cmake
Normal file
5
cmake-d/FindPhobos.cmake
Normal file
|
@ -0,0 +1,5 @@
|
|||
find_path(PHOBOS_INCLUDE_DIR std/file.d)
|
||||
find_library(PHOBOS_LIBRARY phobos2)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Phobos DEFAULT_MSG PHOBOS_LIBRARY PHOBOS_INCLUDE_DIR)
|
63
cmake-d/Platform/Linux-dmd.cmake
Normal file
63
cmake-d/Platform/Linux-dmd.cmake
Normal file
|
@ -0,0 +1,63 @@
|
|||
#
|
||||
# CMakeD - CMake module for D Language
|
||||
#
|
||||
# Copyright (c) 2007, Selman Ulug <selman.ulug@gmail.com>
|
||||
# Tim Burrell <tim.burrell@gmail.com>
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
#SET(DSTDLIB_FLAGS "-version=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_OUTPUT_EXTENSION .o)
|
||||
SET(CMAKE_D_DASH_O "-of")
|
||||
SET(CMAKE_BASE_NAME dmd)
|
||||
|
||||
SET(CMAKE_STATIC_LIBRARY_CREATE_D_FLAGS "-lib")
|
||||
|
||||
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-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-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 "-L-lphobos2 -L-lpthread -L-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 -L--export-dynamic ${DDOC_FLAGS}")
|
||||
# SET (CMAKE_D_CREATE_PREPROCESSED_SOURCE "<CMAKE_D_COMPILER> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
|
||||
SET (CMAKE_D_CREATE_ASSEMBLY_SOURCE "<CMAKE_D_COMPILER> <FLAGS> -S <SOURCE> -of<ASSEMBLY_SOURCE>")
|
||||
# SET (CMAKE_INCLUDE_SYSTEM_FLAG_D "-isystem ")
|
41
cmake-d/Platform/Linux-gdc.cmake
Normal file
41
cmake-d/Platform/Linux-gdc.cmake
Normal file
|
@ -0,0 +1,41 @@
|
|||
#
|
||||
# CMakeD - CMake module for D Language
|
||||
#
|
||||
# Copyright (c) 2007, Selman Ulug <selman.ulug@gmail.com>
|
||||
# Tim Burrell <tim.burrell@gmail.com>
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
SET(CMAKE_D_DASH_O "-o")
|
||||
SET(CMAKE_BASE_NAME gdc)
|
||||
|
||||
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 -fversion=${CMAKE_BUILD_TYPE}Build ${DSTDLIB_FLAGS}")
|
||||
SET (CMAKE_D_FLAGS_INIT "")
|
||||
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 "<CMAKE_D_COMPILER> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
|
||||
SET (CMAKE_D_CREATE_ASSEMBLY_SOURCE "<CMAKE_D_COMPILER> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
|
||||
#SET (CMAKE_INCLUDE_SYSTEM_FLAG_D "-isystem ")
|
||||
|
||||
SET(CMAKE_INCLUDE_FLAG_D "-I") # -I
|
56
cmake-d/Platform/Windows-dmd.cmake
Normal file
56
cmake-d/Platform/Windows-dmd.cmake
Normal file
|
@ -0,0 +1,56 @@
|
|||
#
|
||||
# CMakeD - CMake module for D Language
|
||||
#
|
||||
# Copyright (c) 2007, Selman Ulug <selman.ulug@gmail.com>
|
||||
# Tim Burrell <tim.burrell@gmail.com>
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
#SET(DSTDLIB_FLAGS "-version=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_OUTPUT_EXTENSION .obj)
|
||||
SET(CMAKE_D_DASH_O "-of")
|
||||
SET(CMAKE_BASE_NAME dmd)
|
||||
|
||||
SET(CMAKE_STATIC_LIBRARY_CREATE_D_FLAGS "-lib")
|
||||
|
||||
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-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-l")
|
||||
SET(CMAKE_STATIC_LIBRARY_PREFIX "") #
|
||||
SET(CMAKE_STATIC_LIBRARY_SUFFIX ".lib") # lib
|
||||
SET(CMAKE_SHARED_LIBRARY_PREFIX "") #
|
||||
SET(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") # .dll
|
||||
SET(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe
|
||||
SET(CMAKE_DL_LIBS "dl")
|
||||
|
||||
SET(CMAKE_FIND_LIBRARY_PREFIXES "")
|
||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll")
|
||||
|
||||
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 ${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_ASSEMBLY_SOURCE "<CMAKE_D_COMPILER> <FLAGS> -S <SOURCE> -of<ASSEMBLY_SOURCE>")
|
35
cmake-d/Platform/Windows-gdc.cmake
Normal file
35
cmake-d/Platform/Windows-gdc.cmake
Normal file
|
@ -0,0 +1,35 @@
|
|||
#
|
||||
# CMakeD - CMake module for D Language
|
||||
#
|
||||
# Copyright (c) 2007, Selman Ulug <selman.ulug@gmail.com>
|
||||
# Tim Burrell <tim.burrell@gmail.com>
|
||||
#
|
||||
# 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 -fversion=${CMAKE_BUILD_TYPE}Build ${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 "<CMAKE_D_COMPILER> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
|
||||
SET (CMAKE_D_CREATE_ASSEMBLY_SOURCE "<CMAKE_D_COMPILER> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>")
|
||||
#SET (CMAKE_INCLUDE_SYSTEM_FLAG_D "-isystem ")
|
64
cmake-d/UseDDeps.cmake
Normal file
64
cmake-d/UseDDeps.cmake
Normal file
|
@ -0,0 +1,64 @@
|
|||
# Dependency tracking for D
|
||||
#
|
||||
# Copyright (c) 2010 Jens Mueller <jens.k.mueller@gmx.de>
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# See Copyright.txt for details.
|
||||
#
|
||||
|
||||
macro(add_executable_with_dependencies _target)
|
||||
# extract D source files from arguments
|
||||
foreach(file ${ARGV})
|
||||
if(${file} MATCHES "\\.d$")
|
||||
list(APPEND d_source_files ${file})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
#message("D files in arguments: ${d_source_files}")
|
||||
|
||||
foreach(file IN LISTS d_source_files)
|
||||
set(source_file "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
|
||||
set(dependency_file "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${file}-depend.cmake")
|
||||
set(dependency_files ${dependency_files} ${dependency_file})
|
||||
|
||||
#message("Checking dependencies for ${source_file}")
|
||||
#message("Put into ${dependency_file}")
|
||||
# TODO
|
||||
# better way to get the included directories
|
||||
get_directory_property(include_dirs INCLUDE_DIRECTORIES)
|
||||
set(INCLUDES )
|
||||
foreach(include_dir IN LISTS include_dirs)
|
||||
list(APPEND INCLUDES "${CMAKE_INCLUDE_FLAG_D}${include_dir}")
|
||||
endforeach()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D "CMAKE_D_COMPILER:STRING=${CMAKE_D_COMPILER}"
|
||||
-D "CMAKE_D_FLAGS:STRING=${CMAKE_D_FLAGS}"
|
||||
-D "include_directories:STRING=${INCLUDES}"
|
||||
-D "source_file:STRING=${source_file}"
|
||||
-D "dependency_file:STRING=${dependency_file}"
|
||||
-P "${CMAKE_ROOT}/Modules/dependencies.cmake" # TODO hard coded path
|
||||
)
|
||||
|
||||
# load dependencies from file
|
||||
include(${dependency_file})
|
||||
#message("DEPENDENCIES ${D_DMD_DEPEND}")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${dependency_file}
|
||||
DEPENDS ${D_DMD_DEPEND}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D "CMAKE_D_COMPILER:STRING=${CMAKE_D_COMPILER}"
|
||||
-D "CMAKE_D_FLAGS:STRING=${CMAKE_D_FLAGS}"
|
||||
-D "include_directories:STRING=${INCLUDES}"
|
||||
-D "source_file:STRING=${source_file}"
|
||||
-D "dependency_file:STRING=${dependency_file}"
|
||||
-P "${CMAKE_ROOT}/Modules/dependencies.cmake" # TODO hard coded path
|
||||
COMMENT "Scanning for dependencies"
|
||||
)
|
||||
endforeach()
|
||||
|
||||
add_executable(${ARGV} ${dependency_files})
|
||||
endmacro(add_executable_with_dependencies)
|
73
cmake-d/UseDDoc.cmake
Normal file
73
cmake-d/UseDDoc.cmake
Normal file
|
@ -0,0 +1,73 @@
|
|||
# check if the user wants to build ddocs
|
||||
#
|
||||
# Copyright (c) 2007 Tim Burrell <tim.burrell@gmail.com>
|
||||
#
|
||||
# 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})
|
||||
|
||||
# create index.html
|
||||
set(modString "<html><head><title>${PROJECT_NAME} API Documentation</title></head><body>\n")
|
||||
set(modString "<h>${PROJECT_NAME} API Documentation:<br /></h>\n")
|
||||
set(modString "${modString}<ul>\n")
|
||||
foreach(item ${modules})
|
||||
string(REGEX REPLACE "[a-z0-9]*\\." "" filename ${item})
|
||||
set(modString "${modString}\t<li> <a href=\"${filename}.html\">${item}</a> </li>\n")
|
||||
endforeach(item)
|
||||
set(modString "${modString}</ul>\n")
|
||||
set(modString "${modString}</body></html>\n")
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/documentation/index.html" ${modString})
|
||||
endif (NOT CMAKE_D_BUILD_DOCS)
|
||||
|
37
cmake-d/UseDUnittest.cmake
Normal file
37
cmake-d/UseDUnittest.cmake
Normal file
|
@ -0,0 +1,37 @@
|
|||
# Adding D unittests
|
||||
#
|
||||
# Copyright (c) 2010 Jens Mueller <jens.k.mueller@gmx.de>
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# See Copyright.txt for details.
|
||||
#
|
||||
|
||||
macro(add_unittests _sourcefile)
|
||||
|
||||
set(_testname "${_sourcefile}")
|
||||
set(main_unittest "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/unittest.d")
|
||||
set(_source_file "${CMAKE_CURRENT_SOURCE_DIR}/${_sourcefile}")
|
||||
|
||||
#message("main_unittest ${main_unittest}")
|
||||
#message("testname ${_testname}")
|
||||
#message("_sourcefile ${_source_file}")
|
||||
|
||||
if(NOT EXISTS ${main_unittest})
|
||||
file(WRITE ${main_unittest} "// Generated by UseDUnittest.cmake\nint main() { return 0; }")
|
||||
endif()
|
||||
|
||||
# TODO
|
||||
# better way to get the included directories
|
||||
get_directory_property(include_dirs INCLUDE_DIRECTORIES)
|
||||
set(INCLUDES )
|
||||
foreach(include_dir IN LISTS include_dirs)
|
||||
list(APPEND INCLUDES "${CMAKE_INCLUDE_FLAG_D}${include_dir}")
|
||||
endforeach()
|
||||
|
||||
separate_arguments(CMAKE_D_FLAGS)
|
||||
|
||||
add_test(NAME ${_testname}
|
||||
COMMAND ${CMAKE_D_COMPILER} ${CMAKE_D_FLAGS} ${INCLUDES} ${main_unittest} -unittest -run ${_source_file})
|
||||
|
||||
endmacro(add_unittests)
|
52
cmake-d/dependencies.cmake
Normal file
52
cmake-d/dependencies.cmake
Normal file
|
@ -0,0 +1,52 @@
|
|||
#message("Adding dependencies")
|
||||
|
||||
#message("CMAKE_D_FLAGS: ${CMAKE_D_FLAGS} ")
|
||||
#message("CMAKE_D_COMPILER: ${CMAKE_D_COMPILER} ")
|
||||
#message("include_directories: ${include_directories} ")
|
||||
#message("source file ${source_file}")
|
||||
#message("dependency file ${dependency_file}")
|
||||
|
||||
separate_arguments(CMAKE_D_FLAGS)
|
||||
|
||||
# TODO
|
||||
# need to pass all arguments that are used for building
|
||||
# can't I use the build rule somehow
|
||||
execute_process(COMMAND ${CMAKE_D_COMPILER} ${CMAKE_D_FLAGS} ${include_directories} -deps=${dependency_file}.tmp -o- ${source_file})
|
||||
#message("executing: ${CMAKE_D_COMPILER} ${CMAKE_D_FLAGS} ${include_directories} -deps=${dependency_file}.tmp -o- ${source_file}")
|
||||
|
||||
if(NOT EXISTS ${dependency_file})
|
||||
file(WRITE ${dependency_file} "# Generated by: ${CMAKE_CURRENT_LIST_FILE}\nSET(D_DMD_DEPEND\n)\n\n")
|
||||
endif()
|
||||
|
||||
file(READ ${dependency_file}.tmp depend_text)
|
||||
#message("DEPENDENCIES: ${depend_text}")
|
||||
|
||||
# extract dependencies
|
||||
string(REGEX MATCHALL "\\([^)]*\\)" out ${depend_text})
|
||||
string(REGEX MATCHALL "[^()]+" out ${out})
|
||||
list(REMOVE_DUPLICATES out)
|
||||
list(SORT out)
|
||||
|
||||
foreach(file ${out})
|
||||
set(dependencies "${dependencies} \"${file}\"\n")
|
||||
endforeach()
|
||||
|
||||
# write new dependencies to temporary file
|
||||
file(WRITE ${dependency_file}.tmp "# Generated by: ${CMAKE_CURRENT_LIST_FILE}\nSET(D_DMD_DEPEND\n ${dependencies})\n\n")
|
||||
|
||||
# get old dependencies
|
||||
include(${dependency_file})
|
||||
set(old_dependencies ${D_DMD_DEPEND})
|
||||
# and the new dependencies from temporary file
|
||||
include(${dependency_file}.tmp)
|
||||
|
||||
# did the dependencies change?
|
||||
if(NOT "${D_DMD_DEPEND}" STREQUAL "${old_dependencies}")
|
||||
message("Dependencies changed. Need to build.")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${source_file})
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${dependency_file}.tmp ${dependency_file})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E remove ${dependency_file}.tmp)
|
||||
|
||||
#message("Finished dependencies")
|
Loading…
Add table
Add a link
Reference in a new issue