138 lines
5.1 KiB
CMake
138 lines
5.1 KiB
CMake
# 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
|
|
# <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>
|
|
IF(CMAKE_COMPILER_IS_GDC)
|
|
SET(CMAKE_OUTPUT_D_FLAG "-o ")
|
|
# SET(CMAKE_SHARED_LIBRARY_D_FLAGS "-g -O2 -fPIC")
|
|
# SET(CMAKE_SHARED_LIBRARY_CREATE_D_FLAGS "-shared")
|
|
ELSE(CMAKE_COMPILER_IS_GDC)
|
|
SET(CMAKE_OUTPUT_D_FLAG "-of")
|
|
# SET(CMAKE_SHARED_LIBRARY_D_FLAGS "-g -O -L-fPIC")
|
|
# SET(CMAKE_SHARED_LIBRARY_CREATE_D_FLAGS "-L-shared")
|
|
ENDIF(CMAKE_COMPILER_IS_GDC)
|
|
|
|
|
|
# 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_OUTPUT_D_FLAG}<TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
|
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)
|
|
SET(CMAKE_D_CREATE_STATIC_LIBRARY
|
|
"<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS> "
|
|
"<CMAKE_RANLIB> <TARGET> ")
|
|
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_D_COMPILER> <FLAGS> ${CMAKE_OUTPUT_D_FLAG}<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> <LINK_FLAGS> <OBJECTS> ${CMAKE_OUTPUT_D_FLAG}<TARGET> <LINK_LIBRARIES>")
|
|
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)
|