cmake_modules/CMakePascalInformation.cmake
branchwebgl
changeset 9521 8054d9d775fd
parent 9515 9af6176fcd8f
child 9950 2759212a27de
equal deleted inserted replaced
9282:92af50454cf2 9521:8054d9d775fd
     1 # This file sets the basic flags for the Pascal language in CMake.
     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
     2 # It also loads the available platform file for the system-compiler
     3 # if it exists.
     3 # if it exists.
     4 
     4 
       
     5 # in case fpc ever becomes included in cmake
     5 get_filename_component(CMAKE_BASE_NAME ${CMAKE_Pascal_COMPILER} NAME_WE)
     6 get_filename_component(CMAKE_BASE_NAME ${CMAKE_Pascal_COMPILER} NAME_WE)
     6 set(CMAKE_SYSTEM_AND_Pascal_COMPILER_INFO_FILE
     7 set(CMAKE_SYSTEM_AND_Pascal_COMPILER_INFO_FILE
     7     ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
     8     ${CMAKE_ROOT}/Modules/Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}.cmake)
     8 include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
     9 include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
     9 
    10 
    10 # This section should actually be in Platform/${CMAKE_SYSTME_NAME}-fpc.cmake
    11 # This section should actually be in Platform/${CMAKE_SYSTME_NAME}-fpc.cmake
    11 set(CMAKE_Pascal_FLAGS_INIT "-l- -v0ewn")
       
    12 set(CMAKE_Pascal_FLAGS_DEBUG_INIT "-g -gl -gp -gh")
    12 set(CMAKE_Pascal_FLAGS_DEBUG_INIT "-g -gl -gp -gh")
    13 set(CMAKE_Pascal_FLAGS_MINSIZEREL_INIT "-Os -dNDEBUG")
    13 set(CMAKE_Pascal_FLAGS_MINSIZEREL_INIT "-Os -dNDEBUG")
    14 set(CMAKE_Pascal_FLAGS_RELEASE_INIT "-O3 -dNDEBUG")
    14 set(CMAKE_Pascal_FLAGS_RELEASE_INIT "-O3 -dNDEBUG")
    15 set(CMAKE_Pascal_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -gl -gp")
    15 set(CMAKE_Pascal_FLAGS_RELWITHDEBINFO_INIT "-O2 -g -gl -gp")
    16 
    16 
    31 # Create a set of shared library variable specific to Pascal
    31 # Create a set of shared library variable specific to Pascal
    32 # For 90% of the systems, these are the same flags as the C versions
    32 # For 90% of the systems, these are the same flags as the C versions
    33 # so if these are not set just copy the flags from the c version
    33 # so if these are not set just copy the flags from the c version
    34 
    34 
    35 # No flags supported during linking as a shell script takes care of it
    35 # No flags supported during linking as a shell script takes care of it
    36 if(NOT CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS)
    36 # however to avoid interferences we escape -Wl flags to the Pascal -k
    37 #-dynamiclib -Wl,-headerpad_max_install_names for C
    37 #if(NOT CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS)
    38     set(CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
    38 #-shared (linux) / -dynamiclib -Wl,-headerpad_max_install_names (darwin)
    39 endif(NOT CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS)
    39 #    string(REGEX REPLACE "-Wl," "-k" CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
    40 
    40 #endif(NOT CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS)
    41 if(NOT CMAKE_SHARED_LIBRARY_Pascal_FLAGS)
    41 
    42     #another similarity, fpc: -fPIC  Same as -Cg
    42 if(NOT CMAKE_SHARED_LIBRARY_Pascal_FLAGS AND CMAKE_SHARED_LIBRARY_C_FLAGS)
    43     #(maybe required only for x86_64)
    43 #-fPIC
    44     set(CMAKE_SHARED_LIBRARY_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS})
    44     string(REGEX REPLACE "-Wl," "-k" CMAKE_SHARED_LIBRARY_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS})
    45 endif(NOT CMAKE_SHARED_LIBRARY_Pascal_FLAGS)
    45 endif()
    46 
    46 
    47 if(NOT CMAKE_SHARED_LIBRARY_LINK_Pascal_FLAGS)
    47 if(NOT CMAKE_SHARED_LIBRARY_LINK_Pascal_FLAGS AND CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
    48     set(CMAKE_SHARED_LIBRARY_LINK_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS})
    48 #-rdynamic (linux) / (empty on darwin)
    49 endif(NOT CMAKE_SHARED_LIBRARY_LINK_Pascal_FLAGS)
    49     string(REGEX REPLACE "-Wl," "-k" CMAKE_SHARED_LIBRARY_LINK_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS})
    50 
    50 endif()
    51 #if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG)
    51 
    52 #    set(CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG})
    52 if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG)
    53 #endif(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG)
    53 #-Wl,-rpath,
    54 
    54     set(CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG "-k-rpath")
    55 #if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG_SEP)
    55 endif(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG)
    56 #    set(CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP})
    56 
    57 #endif(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG_SEP)
    57 if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG_SEP)
       
    58     set(CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP})
       
    59 endif(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG_SEP)
    58 
    60 
    59 if(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_Pascal_FLAG)
    61 if(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_Pascal_FLAG)
    60     set(CMAKE_SHARED_LIBRARY_RPATH_LINK_Pascal_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG})
    62 #-Wl,-rpath-link,
       
    63     set(CMAKE_SHARED_LIBRARY_RPATH_LINK_Pascal_FLAG "-k-rpath-link")
    61 endif(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_Pascal_FLAG)
    64 endif(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_Pascal_FLAG)
    62 
    65 
    63 # for most systems a module is the same as a shared library
    66 # for most systems a module is the same as a shared library
    64 # so unless the variable CMAKE_MODULE_EXISTS is set just
    67 # so unless the variable CMAKE_MODULE_EXISTS is set just
    65 # copy the values from the LIBRARY variables
    68 # copy the values from the LIBRARY variables
    67     set(CMAKE_SHARED_MODULE_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_Pascal_FLAGS})
    70     set(CMAKE_SHARED_MODULE_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_Pascal_FLAGS})
    68     set(CMAKE_SHARED_MODULE_CREATE_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS})
    71     set(CMAKE_SHARED_MODULE_CREATE_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS})
    69 endif(NOT CMAKE_MODULE_EXISTS)
    72 endif(NOT CMAKE_MODULE_EXISTS)
    70 
    73 
    71 # repeat for modules
    74 # repeat for modules
    72 if(NOT CMAKE_SHARED_MODULE_CREATE_Pascal_FLAGS)
    75 if(NOT CMAKE_SHARED_MODULE_CREATE_Pascal_FLAGS AND CMAKE_SHARED_MODULE_CREATE_C_FLAGS)
    73     set(CMAKE_SHARED_MODULE_CREATE_Pascal_FLAGS ${CMAKE_SHARED_MODULE_CREATE_C_FLAGS})
    76 # ? (linux) / -bundle -Wl,-headerpad_max_install_names (darwin)
    74 endif(NOT CMAKE_SHARED_MODULE_CREATE_Pascal_FLAGS)
    77     string(REGEX REPLACE "-Wl," "-k" CMAKE_SHARED_MODULE_CREATE_Pascal_FLAGS ${CMAKE_SHARED_MODULE_CREATE_C_FLAGS})
    75 
    78 endif()
    76 if(NOT CMAKE_SHARED_MODULE_Pascal_FLAGS)
    79 
    77     set(CMAKE_SHARED_MODULE_Pascal_FLAGS ${CMAKE_SHARED_MODULE_C_FLAGS})
    80 if(NOT CMAKE_SHARED_MODULE_Pascal_FLAGS AND CMAKE_SHARED_MODULE_C_FLAGS)
    78 endif(NOT CMAKE_SHARED_MODULE_Pascal_FLAGS)
    81     string(REGEX REPLACE "-Wl," "-k" CMAKE_SHARED_MODULE_Pascal_FLAGS ${CMAKE_SHARED_MODULE_C_FLAGS})
       
    82 endif()
    79 
    83 
    80 if(NOT CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG)
    84 if(NOT CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG)
    81     set(CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG})
    85     set(CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG})
    82 endif(NOT CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG)
    86 endif(NOT CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG)
    83 
    87 
    84 if(NOT CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG_SEP)
    88 if(NOT CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG_SEP)
    85     set(CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG_SEP ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG_SEP})
    89     set(CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG_SEP ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG_SEP})
    86 endif(NOT CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG_SEP)
    90 endif(NOT CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG_SEP)
    87 
    91 
       
    92 # now other system things
    88 if(NOT CMAKE_INCLUDE_FLAG_Pascal)
    93 if(NOT CMAKE_INCLUDE_FLAG_Pascal)
    89     #amazing, fpc: -I<x>  Add <x> to include path
    94     #amazing, fpc: -I<x>  Add <x> to include path
    90     set(CMAKE_INCLUDE_FLAG_Pascal ${CMAKE_INCLUDE_FLAG_C})
    95     set(CMAKE_INCLUDE_FLAG_Pascal ${CMAKE_INCLUDE_FLAG_C})
    91 endif(NOT CMAKE_INCLUDE_FLAG_Pascal)
    96 endif(NOT CMAKE_INCLUDE_FLAG_Pascal)
    92 
    97 
    93 if(NOT CMAKE_INCLUDE_FLAG_SEP_Pascal)
    98 if(NOT CMAKE_INCLUDE_FLAG_SEP_Pascal)
    94     set(CMAKE_INCLUDE_FLAG_SEP_Pascal ${CMAKE_INCLUDE_FLAG_SEP_C})
    99     set(CMAKE_INCLUDE_FLAG_SEP_Pascal ${CMAKE_INCLUDE_FLAG_SEP_C})
    95 endif(NOT CMAKE_INCLUDE_FLAG_SEP_Pascal)
   100 endif(NOT CMAKE_INCLUDE_FLAG_SEP_Pascal)
    96 
   101 
       
   102 if(NOT CMAKE_Pascal_FRAMEWORK_SEARCH_FLAG)
       
   103     #however -F won't work, -Ff is Pascal equivalent
       
   104     set(CMAKE_Pascal_FRAMEWORK_SEARCH_FLAG "-Ff")
       
   105 endif(NOT CMAKE_Pascal_FRAMEWORK_SEARCH_FLAG)
       
   106 
    97 # Copy C version of this flag which is normally determined in platform file.
   107 # Copy C version of this flag which is normally determined in platform file.
    98 if(NOT CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG)
   108 if(NOT CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG)
       
   109 #-soname (linux) / -install-name (dawin)
    99     set(CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_C_FLAG})
   110     set(CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_C_FLAG})
   100 endif(NOT CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG)
   111 endif(NOT CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG)
   101 
   112 
   102 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.")
   113 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.")
   103 
   114 
   104 set(CMAKE_Pascal_FLAGS "$ENV{FPFLAGS} ${CMAKE_Pascal_FLAGS_INIT} ${CMAKE_Pascal_FLAGS}" CACHE STRING "Flags for Pascal compiler.")
   115 #set(CMAKE_Pascal_FLAGS "$ENV{FPFLAGS} ${CMAKE_Pascal_FLAGS_INIT} ${CMAKE_Pascal_FLAGS}" CACHE STRING "Flags for Pascal compiler." FORCE)
   105 
   116 
   106 include(CMakeCommonLanguageInclude)
   117 include(CMakeCommonLanguageInclude)
   107 
   118 
   108 # now define the following rule variables
   119 # now define the following rule variables
   109 
   120 
   159 # compile a Pascal file into an object file
   170 # compile a Pascal file into an object file
   160 if(NOT CMAKE_Pascal_COMPILE_OBJECT)
   171 if(NOT CMAKE_Pascal_COMPILE_OBJECT)
   161     if(UNIX)
   172     if(UNIX)
   162         #when you have multiple ld installation make sure you get the one bundled with the system C compiler
   173         #when you have multiple ld installation make sure you get the one bundled with the system C compiler
   163         include(Platform/${CMAKE_SYSTEM_NAME}-GNU-C.cmake OPTIONAL)
   174         include(Platform/${CMAKE_SYSTEM_NAME}-GNU-C.cmake OPTIONAL)
   164         if(CMAKE_C_COMPILER)
   175         if(CMAKE_COMPILER_IS_GNUCC)
   165             get_filename_component(CMAKE_C_COMPILER_DIR ${CMAKE_C_COMPILER} PATH)
   176             get_filename_component(CMAKE_C_COMPILER_DIR ${CMAKE_C_COMPILER} PATH)
   166             set(CMAKE_Pascal_UNIX_FLAGS "-FD${CMAKE_C_COMPILER_DIR}")
   177             set(CMAKE_Pascal_UNIX_FLAGS "-FD${CMAKE_C_COMPILER_DIR}")
   167         endif(CMAKE_C_COMPILER)
   178         endif(CMAKE_COMPILER_IS_GNUCC)
   168         if(APPLE)
   179         if(APPLE)
   169             #add user framework directory
   180             #TODO: take care of CMAKE_INSTALL_NAME_DIR for shared targets
   170             set(CMAKE_Pascal_UNIX_FLAGS "-Ff~/Library/Frameworks ${CMAKE_Pascal_UNIX_FLAGS}")
   181         else(APPLE)
       
   182             if(CMAKE_INSTALL_RPATH)
       
   183                 #need to escape twice because we use a script to link
       
   184                 #\\\\ is just \\ which escapes '\' in the final script
       
   185                 #same for $$ which escapes '$' in cmake
       
   186                 string(REGEX REPLACE "\\$" "\\\\$$" CMAKE_INSTALL_RPATH_ESCAPED ${CMAKE_INSTALL_RPATH})
       
   187                 #normally this flag is found in <LINK_LIBRARIES> but that's not active here
       
   188                 set(CMAKE_Pascal_UNIX_FLAGS "${CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG} -k'${CMAKE_INSTALL_RPATH_ESCAPED}' ${CMAKE_Pascal_UNIX_FLAGS}")
       
   189             endif()
   171         endif(APPLE)
   190         endif(APPLE)
   172     endif(UNIX)
   191     endif(UNIX)
   173 
   192 
       
   193     #-Cn is mandatory as it's what creates the ppas.* script
   174     set(CMAKE_Pascal_COMPILE_OBJECT
   194     set(CMAKE_Pascal_COMPILE_OBJECT
   175         "<CMAKE_Pascal_COMPILER> -Cn -FE${EXECUTABLE_OUTPUT_PATH} -FU${CMAKE_CURRENT_BINARY_DIR}/<OBJECT_DIR> ${CMAKE_Pascal_UNIX_FLAGS} <FLAGS> <SOURCE>")
   195         "<CMAKE_Pascal_COMPILER> -Cn -FE${EXECUTABLE_OUTPUT_PATH} -FU${CMAKE_CURRENT_BINARY_DIR}/<OBJECT_DIR> ${CMAKE_Pascal_UNIX_FLAGS} <FLAGS> <CMAKE_Pascal_LINK_FLAGS> <SOURCE>")
   176 endif(NOT CMAKE_Pascal_COMPILE_OBJECT)
   196 endif(NOT CMAKE_Pascal_COMPILE_OBJECT)
   177 
   197 
   178 # link Pascal objects in a single executable
   198 # link Pascal objects in a single executable
   179 if(NOT CMAKE_Pascal_LINK_EXECUTABLE)
   199 if(NOT CMAKE_Pascal_LINK_EXECUTABLE)
   180     if(WIN32)
   200     if(WIN32)