cmake_modules/CMakePascalInformation.cmake
changeset 9339 14f5f3a1e2f7
parent 9227 c02e081ba481
child 9341 4dfebad83d51
equal deleted inserted replaced
9337:c9d4daae1dee 9339:14f5f3a1e2f7
    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 # however to avoid interferences we escape -Wl flags to the Pascal -k
    36 if(NOT CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS)
    37 if(NOT CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS)
    37 #-dynamiclib -Wl,-headerpad_max_install_names for C
    38 #-shared
    38     set(CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
    39     string(REGEX REPLACE "-Wl," "-k" CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
    39 endif(NOT CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS)
    40 endif(NOT CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS)
    40 
    41 
    41 if(NOT CMAKE_SHARED_LIBRARY_Pascal_FLAGS)
    42 if(NOT CMAKE_SHARED_LIBRARY_Pascal_FLAGS AND CMAKE_SHARED_LIBRARY_C_FLAGS)
    42     #another similarity, fpc: -fPIC  Same as -Cg
    43     string(REGEX REPLACE "-Wl," "-k" CMAKE_SHARED_LIBRARY_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS})
    43     #(maybe required only for x86_64)
    44 endif()
    44     set(CMAKE_SHARED_LIBRARY_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS})
    45 
    45 endif(NOT CMAKE_SHARED_LIBRARY_Pascal_FLAGS)
    46 if(NOT CMAKE_SHARED_LIBRARY_LINK_Pascal_FLAGS AND CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
    46 
    47 #-rdynamic
    47 if(NOT CMAKE_SHARED_LIBRARY_LINK_Pascal_FLAGS)
    48     string(REGEX REPLACE "-Wl," "-k" CMAKE_SHARED_LIBRARY_LINK_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS})
    48     set(CMAKE_SHARED_LIBRARY_LINK_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS})
    49 endif()
    49 endif(NOT CMAKE_SHARED_LIBRARY_LINK_Pascal_FLAGS)
    50 
    50 
    51 if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG)
    51 #if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG)
    52 #-Wl,-rpath,
    52 #    set(CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG})
    53     string(REGEX REPLACE "-Wl," "-k" CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG})
    53 #endif(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG)
    54     string(REGEX REPLACE "," "" CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG})
    54 
    55 endif(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG)
    55 #if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG_SEP)
    56 
    56 #    set(CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG_SEP ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP})
    57 if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG_SEP)
    57 #endif(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     string(REGEX REPLACE "-Wl," "-k" CMAKE_SHARED_LIBRARY_RPATH_LINK_Pascal_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG})
    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
    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)
    73     set(CMAKE_SHARED_MODULE_CREATE_Pascal_FLAGS ${CMAKE_SHARED_MODULE_CREATE_C_FLAGS})
    76     string(REGEX REPLACE "-Wl," "-k" CMAKE_SHARED_MODULE_CREATE_Pascal_FLAGS ${CMAKE_SHARED_MODULE_CREATE_C_FLAGS})
    74 endif(NOT CMAKE_SHARED_MODULE_CREATE_Pascal_FLAGS)
    77 endif(NOT CMAKE_SHARED_MODULE_CREATE_Pascal_FLAGS)
    75 
    78 
    76 if(NOT CMAKE_SHARED_MODULE_Pascal_FLAGS)
    79 if(NOT CMAKE_SHARED_MODULE_Pascal_FLAGS AND CMAKE_SHARED_MODULE_C_FLAGS)
    77     set(CMAKE_SHARED_MODULE_Pascal_FLAGS ${CMAKE_SHARED_MODULE_C_FLAGS})
    80     string(REGEX REPLACE "-Wl," "-k" CMAKE_SHARED_MODULE_Pascal_FLAGS ${CMAKE_SHARED_MODULE_C_FLAGS})
    78 endif(NOT CMAKE_SHARED_MODULE_Pascal_FLAGS)
    81 endif()
    79 
    82 
    80 if(NOT CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG)
    83 if(NOT CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG)
    81     set(CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG})
    84     set(CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG})
    82 endif(NOT CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG)
    85 endif(NOT CMAKE_SHARED_MODULE_RUNTIME_Pascal_FLAG)
    83 
    86 
    94     set(CMAKE_INCLUDE_FLAG_SEP_Pascal ${CMAKE_INCLUDE_FLAG_SEP_C})
    97     set(CMAKE_INCLUDE_FLAG_SEP_Pascal ${CMAKE_INCLUDE_FLAG_SEP_C})
    95 endif(NOT CMAKE_INCLUDE_FLAG_SEP_Pascal)
    98 endif(NOT CMAKE_INCLUDE_FLAG_SEP_Pascal)
    96 
    99 
    97 # Copy C version of this flag which is normally determined in platform file.
   100 # Copy C version of this flag which is normally determined in platform file.
    98 if(NOT CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG)
   101 if(NOT CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG)
    99     set(CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_C_FLAG})
   102     string(REGEX REPLACE "-Wl," "-k" CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG ${CMAKE_SHARED_LIBRARY_SONAME_C_FLAG})
   100 endif(NOT CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG)
   103 endif(NOT CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG)
   101 
   104 
   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.")
   105 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 
   106 
   104 set(CMAKE_Pascal_FLAGS "$ENV{FPFLAGS} ${CMAKE_Pascal_FLAGS_INIT} ${CMAKE_Pascal_FLAGS}" CACHE STRING "Flags for Pascal compiler.")
   107 set(CMAKE_Pascal_FLAGS "$ENV{FPFLAGS} ${CMAKE_Pascal_FLAGS_INIT} ${CMAKE_Pascal_FLAGS}" CACHE STRING "Flags for Pascal compiler.")
   159 # compile a Pascal file into an object file
   162 # compile a Pascal file into an object file
   160 if(NOT CMAKE_Pascal_COMPILE_OBJECT)
   163 if(NOT CMAKE_Pascal_COMPILE_OBJECT)
   161     if(UNIX)
   164     if(UNIX)
   162         #when you have multiple ld installation make sure you get the one bundled with the system C compiler
   165         #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)
   166         include(Platform/${CMAKE_SYSTEM_NAME}-GNU-C.cmake OPTIONAL)
   164         if(CMAKE_C_COMPILER)
   167         if(CMAKE_COMPILER_IS_GNUCC)
   165             get_filename_component(CMAKE_C_COMPILER_DIR ${CMAKE_C_COMPILER} PATH)
   168             get_filename_component(CMAKE_C_COMPILER_DIR ${CMAKE_C_COMPILER} PATH)
   166             set(CMAKE_Pascal_UNIX_FLAGS "-FD${CMAKE_C_COMPILER_DIR}")
   169             set(CMAKE_Pascal_UNIX_FLAGS "-FD${CMAKE_C_COMPILER_DIR}")
   167         endif(CMAKE_C_COMPILER)
   170         endif(CMAKE_COMPILER_IS_GNUCC)
   168         if(APPLE)
   171         if(APPLE)
   169             #add user framework directory
   172             #TODO: take care of CMAKE_INSTALL_NAME_DIR for shared targets
   170             set(CMAKE_Pascal_UNIX_FLAGS "-Ff~/Library/Frameworks ${CMAKE_Pascal_UNIX_FLAGS}")
   173         else(APPLE)
       
   174             if(CMAKE_INSTALL_RPATH)
       
   175                 #need to escape twice because we use a script to link
       
   176                 #\\\\ is just \\ which escapes '\' in the final script
       
   177                 #same for $$ which escapes '$' in cmake
       
   178                 string(REGEX REPLACE "\\$" "\\\\$$" CMAKE_INSTALL_RPATH_ESCAPED ${CMAKE_INSTALL_RPATH})
       
   179                 #normally this flag is found in <LINK_LIBRARIES> but that's not active here
       
   180                 set(CMAKE_Pascal_UNIX_FLAGS "${CMAKE_SHARED_LIBRARY_RUNTIME_Pascal_FLAG} -k'${CMAKE_INSTALL_RPATH_ESCAPED}' ${CMAKE_Pascal_UNIX_FLAGS}")
       
   181             endif()
   171         endif(APPLE)
   182         endif(APPLE)
   172     endif(UNIX)
   183     endif(UNIX)
   173 
   184 
       
   185     #-Cn is mandatory as it's what creates the ppas.* script
   174     set(CMAKE_Pascal_COMPILE_OBJECT
   186     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>")
   187         "<CMAKE_Pascal_COMPILER> -Cn -FE${EXECUTABLE_OUTPUT_PATH} -FU${CMAKE_CURRENT_BINARY_DIR}/<OBJECT_DIR> ${CMAKE_Pascal_UNIX_FLAGS} <FLAGS> <SOURCE>")
   176 endif(NOT CMAKE_Pascal_COMPILE_OBJECT)
   188 endif(NOT CMAKE_Pascal_COMPILE_OBJECT)
   177 
   189 
   178 # link Pascal objects in a single executable
   190 # link Pascal objects in a single executable