# 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(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") ELSE(CMAKE_COMPILER_IS_GDC) SET(CMAKE_OUTPUT_D_FLAG "-of") IF(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") # not a good way but works because dmd using gcc # for linker on Linux SET(CMAKE_LINK_LIBRARY_FLAG "-L-l") SET(CMAKE_LIBRARY_PATH_FLAG "-L-L") ELSE(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") # dmd part doesn't work for now SET(CMAKE_LINK_LIBRARY_FLAG "-L+") SET(CMAKE_LIBRARY_PATH_FLAG "-I") ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") ENDIF(CMAKE_COMPILER_IS_GDC) # create a D shared library IF(NOT CMAKE_D_CREATE_SHARED_LIBRARY) SET(CMAKE_D_CREATE_SHARED_LIBRARY " ${CMAKE_OUTPUT_D_FLAG} ") 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 " cr " " ") 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) SET(CMAKE_D_LINK_EXECUTABLE " ${CMAKE_OUTPUT_D_FLAG} ") 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)