cmake_modules/CMakePascalInformation.cmake
branchcmake_pascal
changeset 8750 d9e57426e759
child 8752 48cf2ccb83c6
equal deleted inserted replaced
8749:1b9f026e9fc6 8750:d9e57426e759
       
     1 # This file sets the basic flags for the Pascal language in CMake.
       
     2 # It also loads the available platform file for the system-compiler
       
     3 # if it exists.
       
     4 
       
     5 GET_FILENAME_COMPONENT(CMAKE_BASE_NAME ${CMAKE_Pascal_COMPILER} NAME_WE)
       
     6 SET(CMAKE_SYSTEM_AND_Pascal_COMPILER_INFO_FILE
       
     7   ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
       
     8 INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
       
     9 
       
    10 # This should be included before the _INIT variables are
       
    11 # used to initialize the cache.  Since the rule variables 
       
    12 # have if blocks on them, users can still define them here.
       
    13 # But, it should still be after the platform file so changes can
       
    14 # be made to those values.
       
    15 
       
    16 IF(CMAKE_USER_MAKE_RULES_OVERRIDE)
       
    17    INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE})
       
    18 ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE)
       
    19 
       
    20 IF(CMAKE_USER_MAKE_RULES_OVERRIDE_Pascal)
       
    21    INCLUDE(${CMAKE_USER_MAKE_RULES_OVERRIDE_Pascal})
       
    22 ENDIF(CMAKE_USER_MAKE_RULES_OVERRIDE_Pascal)
       
    23 
       
    24 
       
    25 # for most systems a module is the same as a shared library
       
    26 # so unless the variable CMAKE_MODULE_EXISTS is set just
       
    27 # copy the values from the LIBRARY variables
       
    28 IF(NOT CMAKE_MODULE_EXISTS)
       
    29   SET(CMAKE_SHARED_MODULE_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_Pascal_FLAGS})
       
    30   SET(CMAKE_SHARED_MODULE_CREATE_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS})
       
    31 ENDIF(NOT CMAKE_MODULE_EXISTS)
       
    32 
       
    33 # Create a set of shared library variable specific to Pascal
       
    34 # For 90% of the systems, these are the same flags as the C versions
       
    35 # so if these are not set just copy the flags from the c version
       
    36 #IF(NOT CMAKE_SHARED_LIBRARY_CREATE_Ada_FLAGS)
       
    37 #  SET(CMAKE_SHARED_LIBRARY_CREATE_Ada_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
       
    38 #ENDIF(NOT CMAKE_SHARED_LIBRARY_CREATE_Ada_FLAGS)
       
    39 
       
    40 #IF(NOT CMAKE_SHARED_LIBRARY_Ada_FLAGS)
       
    41 #  SET(CMAKE_SHARED_LIBRARY_Ada_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS})
       
    42 #ENDIF(NOT CMAKE_SHARED_LIBRARY_Ada_FLAGS)
       
    43 
       
    44 #IF(NOT CMAKE_SHARED_LIBRARY_LINK_Ada_FLAGS)
       
    45 #  SET(CMAKE_SHARED_LIBRARY_LINK_Ada_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS})
       
    46 #ENDIF(NOT CMAKE_SHARED_LIBRARY_LINK_Ada_FLAGS)
       
    47 
       
    48 #IF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG)
       
    49 #  SET(CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG}) 
       
    50 #ENDIF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG)
       
    51 
       
    52 #IF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG_SEP)
       
    53 #  SET(CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP})
       
    54 #ENDIF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG_SEP)
       
    55 
       
    56 # repeat for modules
       
    57 #IF(NOT CMAKE_SHARED_MODULE_CREATE_Ada_FLAGS)
       
    58 #  SET(CMAKE_SHARED_MODULE_CREATE_Ada_FLAGS ${CMAKE_SHARED_MODULE_CREATE_C_FLAGS})
       
    59 #ENDIF(NOT CMAKE_SHARED_MODULE_CREATE_Ada_FLAGS)
       
    60 
       
    61 #IF(NOT CMAKE_SHARED_MODULE_Ada_FLAGS)
       
    62 #  SET(CMAKE_SHARED_MODULE_Ada_FLAGS ${CMAKE_SHARED_MODULE_C_FLAGS})
       
    63 #ENDIF(NOT CMAKE_SHARED_MODULE_Ada_FLAGS)
       
    64 
       
    65 #IF(NOT CMAKE_SHARED_MODULE_RUNTIME_Ada_FLAG)
       
    66 #  SET(CMAKE_SHARED_MODULE_RUNTIME_Ada_FLAG ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG}) 
       
    67 #ENDIF(NOT CMAKE_SHARED_MODULE_RUNTIME_Ada_FLAG)
       
    68 
       
    69 #IF(NOT CMAKE_SHARED_MODULE_RUNTIME_Ada_FLAG_SEP)
       
    70 #  SET(CMAKE_SHARED_MODULE_RUNTIME_Ada_FLAG_SEP ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG_SEP})
       
    71 #ENDIF(NOT CMAKE_SHARED_MODULE_RUNTIME_Ada_FLAG_SEP)
       
    72 
       
    73 #IF(NOT CMAKE_INCLUDE_FLAG_Ada)
       
    74 #  SET(CMAKE_INCLUDE_FLAG_Ada ${CMAKE_INCLUDE_FLAG_C})
       
    75 #ENDIF(NOT CMAKE_INCLUDE_FLAG_Ada)
       
    76 
       
    77 #IF(NOT CMAKE_INCLUDE_FLAG_SEP_Ada)
       
    78 #  SET(CMAKE_INCLUDE_FLAG_SEP_Ada ${CMAKE_INCLUDE_FLAG_SEP_C})
       
    79 #ENDIF(NOT CMAKE_INCLUDE_FLAG_SEP_Ada)
       
    80 
       
    81 # Copy C version of this flag which is normally determined in platform file.
       
    82 IF(NOT CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG)
       
    83   SET(CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_C_FLAG})
       
    84 ENDIF(NOT CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG)
       
    85 
       
    86 SET(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make.  This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.")
       
    87 
       
    88 SET (CMAKE_Pascal_FLAGS "$ENV{FPFLAGS} ${CMAKE_Pascal_FLAGS_INIT}" CACHE STRING
       
    89      "Flags for Ada compiler.")
       
    90 
       
    91 INCLUDE(CMakeCommonLanguageInclude)
       
    92 
       
    93 # now define the following rule variables
       
    94 
       
    95 # CMAKE_Ada_CREATE_SHARED_LIBRARY
       
    96 # CMAKE_Ada_CREATE_SHARED_MODULE
       
    97 # CMAKE_Ada_CREATE_STATIC_LIBRARY
       
    98 # CMAKE_Ada_COMPILE_OBJECT
       
    99 # CMAKE_Ada_LINK_EXECUTABLE
       
   100 
       
   101 # variables supplied by the generator at use time
       
   102 # <TARGET>
       
   103 # <TARGET_BASE> the target without the suffix
       
   104 # <OBJECTS>
       
   105 # <OBJECT>
       
   106 # <LINK_LIBRARIES>
       
   107 # <FLAGS>
       
   108 # <LINK_FLAGS>
       
   109 
       
   110 # Ada compiler information
       
   111 # <CMAKE_Ada_COMPILER>  
       
   112 # <CMAKE_SHARED_LIBRARY_CREATE_Ada_FLAGS>
       
   113 # <CMAKE_SHARED_MODULE_CREATE_Ada_FLAGS>
       
   114 # <CMAKE_Ada_LINK_FLAGS>
       
   115 
       
   116 # Static library tools
       
   117 # <CMAKE_AR> 
       
   118 # <CMAKE_RANLIB>
       
   119 
       
   120 
       
   121 # create an Ada shared library
       
   122 IF(NOT CMAKE_Ada_CREATE_SHARED_LIBRARY)
       
   123     SET(CMAKE_Ada_CREATE_SHARED_LIBRARY
       
   124     "<CMAKE_Ada_COMPILER> <CMAKE_SHARED_LIBRARY_Ada_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_Ada_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_Ada_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>"
       
   125     )
       
   126 ENDIF(NOT CMAKE_Ada_CREATE_SHARED_LIBRARY)
       
   127 
       
   128 # create an Ada shared module just copy the shared library rule
       
   129 IF(NOT CMAKE_Ada_CREATE_SHARED_MODULE)
       
   130   SET(CMAKE_Ada_CREATE_SHARED_MODULE ${CMAKE_Ada_CREATE_SHARED_LIBRARY})
       
   131 ENDIF(NOT CMAKE_Ada_CREATE_SHARED_MODULE)
       
   132 
       
   133 # create an Ada static library
       
   134 IF(NOT CMAKE_Ada_CREATE_STATIC_LIBRARY)
       
   135   SET(CMAKE_Ada_CREATE_STATIC_LIBRARY
       
   136       "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS> "
       
   137       "<CMAKE_RANLIB> <TARGET> ")
       
   138 ENDIF(NOT CMAKE_Ada_CREATE_STATIC_LIBRARY)
       
   139 
       
   140 # compile a Pascal file into an object file
       
   141 IF(NOT CMAKE_Pascal_COMPILE_OBJECT)
       
   142   SET(CMAKE_Pascal_COMPILE_OBJECT "<CMAKE_Pascal_COMPILER> <FLAGS> <SOURCE> -Cn")
       
   143 #"<CMAKE_Pascal_COMPILER> <FLAGS> <SOURCE> -o<OBJECT> -Cn
       
   144 ENDIF(NOT CMAKE_Pascal_COMPILE_OBJECT)
       
   145 
       
   146 # Constraints:  GNAT_EXECUTABLE_BUILDER = gnatmake
       
   147 # is required to do the compile+bind+link of
       
   148 # Ada executables, and it requires a source file name which is constructed from
       
   149 # <TARGET>.adb.  The source file arguments of add_executable are
       
   150 # all compiled by the above rule (which must remain that form since it
       
   151 # is also used to compile objects for Ada libraries), but the results are
       
   152 # ignored since they are put in a different directory while gnatmake assumes
       
   153 # objects are located in the _current_ directory.  Thus, put in a minimal
       
   154 # source file (with correct .adb suffix to identify the Ada language)
       
   155 # to reduce this useless compilation to a minimum.  Usually, the main Ada
       
   156 # routine qualifies since it is normally small.  Thus, the normal usage is
       
   157 # add_executable(foo foo.adb), but  add_executable(foo path/minimal.adb) would
       
   158 # work as well so long as both path/minimal.adb existed and foo.adb existed.
       
   159 # Also, note there is no way to specify 
       
   160 # ${CMAKE_CURRENT_SOURCE_DIR}/<TARGET>.adb as the code for gnatmake to compile
       
   161 # because in this context ${CMAKE_CURRENT_SOURCE_DIR} is set to the top
       
   162 # of the source tree and not the expected sub-directory of the source tree.
       
   163 # Thus, LINK_FLAGS -aI${CMAKE_CURRENT_SOURCE_DIR} must be set using
       
   164 # set_target_properties in order to specify the directory where <TARGET>.adb
       
   165 # exists. Note, LINK_FLAGS can also be used to set other gnatmake flags
       
   166 # such as -aL.
       
   167 
       
   168 # In sum, you have to be careful of your target name, the nominal source file
       
   169 # name has to be compilable, but otherwise it is ignored, and you must specify
       
   170 # the required -aI and other GNAT_EXECUTABLE_BUILDER = gnatmake options
       
   171 # using LINK_FLAGS specified with set_target_properties.  
       
   172 # However, so long as you pay attention to these
       
   173 # constraints, add_executable should work for the Ada language.
       
   174 
       
   175 IF(NOT CMAKE_Pascal_LINK_EXECUTABLE)
       
   176 #GET_FILENAME_COMPONENT(COMPILER_LOCATION "${CMAKE_Pascal_COMPILER}" PATH)
       
   177     set(CMAKE_Pascal_LINK_EXECUTABLE "${CMAKE_BINARY_DIR}/ppas.sh")
       
   178 #  SET(CMAKE_Pascal_LINK_EXECUTABLE "${CMAKE_Pascal_COMPILER} <CMAKE_Ada_LINK_FLAGS> <LINK_FLAGS> <TARGET_BASE>.adb -cargs <FLAGS> -largs <LINK_LIBRARIES>")
       
   179 ENDIF(NOT CMAKE_Pascal_LINK_EXECUTABLE)
       
   180 
       
   181 IF(CMAKE_Ada_STANDARD_LIBRARIES_INIT)
       
   182   SET(CMAKE_Ada_STANDARD_LIBRARIES "${CMAKE_Ada_STANDARD_LIBRARIES_INIT}"
       
   183     CACHE STRING "Libraries linked by default with all Ada applications.")
       
   184   MARK_AS_ADVANCED(CMAKE_Ada_STANDARD_LIBRARIES)
       
   185 ENDIF(CMAKE_Ada_STANDARD_LIBRARIES_INIT)
       
   186 
       
   187 IF(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
       
   188   SET (CMAKE_Ada_FLAGS_DEBUG "${CMAKE_Ada_FLAGS_DEBUG_INIT}" CACHE STRING
       
   189      "Flags used by the compiler during debug builds.")
       
   190   SET (CMAKE_Ada_FLAGS_MINSIZEREL "${CMAKE_Ada_FLAGS_MINSIZEREL_INIT}" CACHE STRING
       
   191      "Flags used by the compiler during release minsize builds.")
       
   192   SET (CMAKE_Ada_FLAGS_RELEASE "${CMAKE_Ada_FLAGS_RELEASE_INIT}" CACHE STRING
       
   193      "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).")
       
   194   SET (CMAKE_Ada_FLAGS_RELWITHDEBINFO "${CMAKE_Ada_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING
       
   195      "Flags used by the compiler during Release with Debug Info builds.")
       
   196 ENDIF(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
       
   197 
       
   198 MARK_AS_ADVANCED(
       
   199 CMAKE_Pascal_FLAGS
       
   200 CMAKE_Pascal_FLAGS_DEBUG
       
   201 CMAKE_Pascal_FLAGS_MINSIZEREL
       
   202 CMAKE_Pascal_FLAGS_RELEASE
       
   203 CMAKE_Pascal_FLAGS_RELWITHDEBINFO
       
   204 )
       
   205 SET(CMAKE_Pascal_INFORMATION_LOADED 1)
       
   206