32 |
32 |
33 # Create a set of shared library variable specific to Pascal |
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 |
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 |
35 # so if these are not set just copy the flags from the c version |
36 #IF(NOT CMAKE_SHARED_LIBRARY_CREATE_Ada_FLAGS) |
36 #IF(NOT CMAKE_SHARED_LIBRARY_CREATE_Ada_FLAGS) |
|
37 #-dynamiclib -Wl,-headerpad_max_install_names for C |
37 # SET(CMAKE_SHARED_LIBRARY_CREATE_Ada_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}) |
38 # SET(CMAKE_SHARED_LIBRARY_CREATE_Ada_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}) |
38 #ENDIF(NOT CMAKE_SHARED_LIBRARY_CREATE_Ada_FLAGS) |
39 #ENDIF(NOT CMAKE_SHARED_LIBRARY_CREATE_Ada_FLAGS) |
39 |
40 |
40 #IF(NOT CMAKE_SHARED_LIBRARY_Ada_FLAGS) |
41 IF(NOT CMAKE_SHARED_LIBRARY_Pascal_FLAGS) |
41 # SET(CMAKE_SHARED_LIBRARY_Ada_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS}) |
42 #another similarity, fpc: -fPIC Same as -Cg |
42 #ENDIF(NOT CMAKE_SHARED_LIBRARY_Ada_FLAGS) |
43 SET(CMAKE_SHARED_LIBRARY_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS}) |
|
44 ENDIF(NOT CMAKE_SHARED_LIBRARY_Pascal_FLAGS) |
43 |
45 |
44 #IF(NOT CMAKE_SHARED_LIBRARY_LINK_Ada_FLAGS) |
46 IF(NOT CMAKE_SHARED_LIBRARY_LINK_Pascal_FLAGS) |
45 # SET(CMAKE_SHARED_LIBRARY_LINK_Ada_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}) |
47 SET(CMAKE_SHARED_LIBRARY_LINK_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}) |
46 #ENDIF(NOT CMAKE_SHARED_LIBRARY_LINK_Ada_FLAGS) |
48 ENDIF(NOT CMAKE_SHARED_LIBRARY_LINK_Pascal_FLAGS) |
47 |
49 |
48 #IF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG) |
50 #IF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG) |
49 # SET(CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG}) |
51 # SET(CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG}) |
50 #ENDIF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG) |
52 #ENDIF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG) |
51 |
53 |
52 #IF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG_SEP) |
54 #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}) |
55 # 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) |
56 #ENDIF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG_SEP) |
|
57 |
|
58 if(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_Pascal_FLAG) |
|
59 set(CMAKE_SHARED_LIBRARY_RPATH_LINK_Pascal_FLAG ${CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG}) |
|
60 endif(NOT CMAKE_SHARED_LIBRARY_RPATH_LINK_Pascal_FLAG) |
|
61 |
|
62 # for most systems a module is the same as a shared library |
|
63 # so unless the variable CMAKE_MODULE_EXISTS is set just |
|
64 # copy the values from the LIBRARY variables |
|
65 if(NOT CMAKE_MODULE_EXISTS) |
|
66 set(CMAKE_SHARED_MODULE_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_Pascal_FLAGS}) |
|
67 set(CMAKE_SHARED_MODULE_CREATE_Pascal_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_Pascal_FLAGS}) |
|
68 endif() |
55 |
69 |
56 # repeat for modules |
70 # repeat for modules |
57 #IF(NOT CMAKE_SHARED_MODULE_CREATE_Ada_FLAGS) |
71 #IF(NOT CMAKE_SHARED_MODULE_CREATE_Ada_FLAGS) |
58 # SET(CMAKE_SHARED_MODULE_CREATE_Ada_FLAGS ${CMAKE_SHARED_MODULE_CREATE_C_FLAGS}) |
72 # SET(CMAKE_SHARED_MODULE_CREATE_Ada_FLAGS ${CMAKE_SHARED_MODULE_CREATE_C_FLAGS}) |
59 #ENDIF(NOT CMAKE_SHARED_MODULE_CREATE_Ada_FLAGS) |
73 #ENDIF(NOT CMAKE_SHARED_MODULE_CREATE_Ada_FLAGS) |
143 |
157 |
144 # compile a Pascal file into an object file |
158 # compile a Pascal file into an object file |
145 IF(NOT CMAKE_Pascal_COMPILE_OBJECT) |
159 IF(NOT CMAKE_Pascal_COMPILE_OBJECT) |
146 SET(CMAKE_Pascal_COMPILE_OBJECT |
160 SET(CMAKE_Pascal_COMPILE_OBJECT |
147 "<CMAKE_Pascal_COMPILER> -Cn -FE${EXECUTABLE_OUTPUT_PATH} -FU${CMAKE_CURRENT_BINARY_DIR}/<OBJECT_DIR> -Fi${CMAKE_CURRENT_BINARY_DIR} <FLAGS> <SOURCE>") |
161 "<CMAKE_Pascal_COMPILER> -Cn -FE${EXECUTABLE_OUTPUT_PATH} -FU${CMAKE_CURRENT_BINARY_DIR}/<OBJECT_DIR> -Fi${CMAKE_CURRENT_BINARY_DIR} <FLAGS> <SOURCE>") |
148 #"<CMAKE_Pascal_COMPILER> <FLAGS> <SOURCE> -o<OBJECT> -Cn |
|
149 ENDIF(NOT CMAKE_Pascal_COMPILE_OBJECT) |
162 ENDIF(NOT CMAKE_Pascal_COMPILE_OBJECT) |
150 |
163 |
151 # Constraints: GNAT_EXECUTABLE_BUILDER = gnatmake |
|
152 # is required to do the compile+bind+link of |
|
153 # Ada executables, and it requires a source file name which is constructed from |
|
154 # <TARGET>.adb. The source file arguments of add_executable are |
|
155 # all compiled by the above rule (which must remain that form since it |
|
156 # is also used to compile objects for Ada libraries), but the results are |
|
157 # ignored since they are put in a different directory while gnatmake assumes |
|
158 # objects are located in the _current_ directory. Thus, put in a minimal |
|
159 # source file (with correct .adb suffix to identify the Ada language) |
|
160 # to reduce this useless compilation to a minimum. Usually, the main Ada |
|
161 # routine qualifies since it is normally small. Thus, the normal usage is |
|
162 # add_executable(foo foo.adb), but add_executable(foo path/minimal.adb) would |
|
163 # work as well so long as both path/minimal.adb existed and foo.adb existed. |
|
164 # Also, note there is no way to specify |
|
165 # ${CMAKE_CURRENT_SOURCE_DIR}/<TARGET>.adb as the code for gnatmake to compile |
|
166 # because in this context ${CMAKE_CURRENT_SOURCE_DIR} is set to the top |
|
167 # of the source tree and not the expected sub-directory of the source tree. |
|
168 # Thus, LINK_FLAGS -aI${CMAKE_CURRENT_SOURCE_DIR} must be set using |
|
169 # set_target_properties in order to specify the directory where <TARGET>.adb |
|
170 # exists. Note, LINK_FLAGS can also be used to set other gnatmake flags |
|
171 # such as -aL. |
|
172 |
|
173 # In sum, you have to be careful of your target name, the nominal source file |
|
174 # name has to be compilable, but otherwise it is ignored, and you must specify |
|
175 # the required -aI and other GNAT_EXECUTABLE_BUILDER = gnatmake options |
|
176 # using LINK_FLAGS specified with set_target_properties. |
|
177 # However, so long as you pay attention to these |
|
178 # constraints, add_executable should work for the Ada language. |
|
179 |
164 |
180 IF(NOT CMAKE_Pascal_LINK_EXECUTABLE) |
165 IF(NOT CMAKE_Pascal_LINK_EXECUTABLE) |
181 #GET_FILENAME_COMPONENT(COMPILER_LOCATION "${CMAKE_Pascal_COMPILER}" PATH) |
166 #GET_FILENAME_COMPONENT(COMPILER_LOCATION "${CMAKE_Pascal_COMPILER}" PATH) |
182 message("look here ${CMAKE_CURRENT_BINARY_DIR} ${EXECUTABLE_OUTPUT_PATH}") |
|
183 set(CMAKE_Pascal_LINK_EXECUTABLE "${EXECUTABLE_OUTPUT_PATH}/ppas.sh") |
167 set(CMAKE_Pascal_LINK_EXECUTABLE "${EXECUTABLE_OUTPUT_PATH}/ppas.sh") |
184 # SET(CMAKE_Pascal_LINK_EXECUTABLE "${CMAKE_Pascal_COMPILER} <CMAKE_Ada_LINK_FLAGS> <LINK_FLAGS> <TARGET_BASE>.adb -cargs <FLAGS> -largs <LINK_LIBRARIES>") |
168 # SET(CMAKE_Pascal_LINK_EXECUTABLE "${CMAKE_Pascal_COMPILER} <CMAKE_Pascal_LINK_FLAGS> <LINK_FLAGS> <TARGET_BASE>.adb -cargs <FLAGS> -largs <LINK_LIBRARIES>") |
185 ENDIF(NOT CMAKE_Pascal_LINK_EXECUTABLE) |
169 ENDIF(NOT CMAKE_Pascal_LINK_EXECUTABLE) |
186 |
170 |
187 IF(CMAKE_Ada_STANDARD_LIBRARIES_INIT) |
171 IF(CMAKE_Ada_STANDARD_LIBRARIES_INIT) |
188 SET(CMAKE_Ada_STANDARD_LIBRARIES "${CMAKE_Ada_STANDARD_LIBRARIES_INIT}" |
172 SET(CMAKE_Ada_STANDARD_LIBRARIES "${CMAKE_Ada_STANDARD_LIBRARIES_INIT}" |
189 CACHE STRING "Libraries linked by default with all Ada applications.") |
173 CACHE STRING "Libraries linked by default with all Ada applications.") |