aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/dists
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cmake/dists/cmake/Modules/ConfigurePasFile.cmake28
-rw-r--r--cmake/dists/cmake/Modules/FindPPC.cmake38
-rw-r--r--cmake/dists/cmake/Modules/UsePascal.cmake164
3 files changed, 146 insertions, 84 deletions
diff --git a/cmake/dists/cmake/Modules/ConfigurePasFile.cmake b/cmake/dists/cmake/Modules/ConfigurePasFile.cmake
deleted file mode 100644
index 803afc1d..00000000
--- a/cmake/dists/cmake/Modules/ConfigurePasFile.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright (c) 2009 Tobias Gunkel <tobigun@at@users.sourceforge.net>
-#
-# Copying and distribution of this file, with or without
-# modification, are permitted in any medium without royalty provided
-# the copyright notice and this notice are preserved.
-
-# - Macro for handling Pascal configuration files
-#
-# CONFIGURE_PAS_FILE(InputFile OutputFile)
-# Works as configure_file(InputFile OutputFile) but in addition
-# it replaces occurences of {$CMAKEDEFINE(VAR) XYZ} with
-# {$DEFINE XYZ} if the value of VAR is true
-# {$UNDEF XYZ} if the value of VAR is false
-
-macro(CONFIGURE_PAS_FILE)
- file(READ ${ARGV0} config_file)
- string(REGEX MATCHALL "{\\$CMAKEDEFINE\\([^\\)]+\\)" pasdefine_list "${config_file}")
- foreach(pasdefine ${pasdefine_list})
- string(REGEX REPLACE "{\\$CMAKEDEFINE\\(([^\\)]+)\\)" "\\1" pasdefine_var ${pasdefine})
- if (${pasdefine_var})
- string(REPLACE ${pasdefine} "{$DEFINE" config_file "${config_file}")
- else (${pasdefine_var})
- string(REPLACE ${pasdefine} "{$UNDEF" config_file "${config_file}")
- endif (${pasdefine_var})
- endforeach(pasdefine)
- string(CONFIGURE "${config_file}" config_file)
- file(WRITE ${ARGV1} "${config_file}")
-endmacro(CONFIGURE_PAS_FILE)
diff --git a/cmake/dists/cmake/Modules/FindPPC.cmake b/cmake/dists/cmake/Modules/FindPPC.cmake
index 67b49dd9..3f82b720 100644
--- a/cmake/dists/cmake/Modules/FindPPC.cmake
+++ b/cmake/dists/cmake/Modules/FindPPC.cmake
@@ -103,6 +103,29 @@ foreach(once 1)
set(FPC_TARGET "${FPC_PROCESSOR}-${FPC_PLATFORM}")
+ #-v -l verbose/banner
+ #-n ignore fpc.cfg
+ #-Fi -I include-dir
+ #-k
+ #-Fl linker-dir
+ #-Fo -Fu object-/unit-dir
+ #-Xt -Xc
+ #-Ciort range checks
+ #-Cs -Ch stack/heap size
+ #-Cg -fPIC PIC code
+ #-E
+ #-g -gv -gw(2/3) -gh -gl -pg
+ #-O
+ #-T -Xd -XP cross-compiling
+ #-d -u define/undefine
+ #-Xs strip
+ #-B build all modules
+ #-Dd -Dv description + DLL-version
+
+ #PFLAGS_BASE_DEFAULT := -Si -Sg- -Sc- -v0Binwe
+ #PFLAGS_DEBUG_DEFAULT := -Xs- -g -gl -dDEBUG_MODE
+ #PFLAGS_RELEASE_DEFAULT := -Xs- -O2
+
##
# Compiler checks
##
@@ -142,14 +165,19 @@ foreach(once 1)
ppc_check(testlib.pas "library link;\nbegin\nend."
"${default_flags}" check_result
NO_CLEAN)
- find_library(libpath testlib
+ # find generated library
+ find_library(PPC_TEST_LIBPATH testlib
PATHS ${PPC_CHECK_DIR}
NO_DEFAULT_PATH)
- if(libpath)
- get_filename_component(PPC_LIBRARY_SUFFIX ${libpath} EXT CACHE)
- get_filename_component(libfilename ${libpath} NAME_WE)
+ # do not show library name in GUI
+ mark_as_advanced(PPC_TEST_LIBPATH)
+ # extract prefix and suffix from library name
+ if(PPC_TEST_LIBPATH)
+ get_filename_component(PPC_LIBRARY_SUFFIX ${PPC_TEST_LIBPATH} EXT CACHE)
+ get_filename_component(libfilename ${PPC_TEST_LIBPATH} NAME_WE)
string(REGEX REPLACE "^(.*)testlib.*" "\\1" PPC_LIBRARY_PREFIX ${libfilename})
- endif(libpath)
+ endif(PPC_TEST_LIBPATH)
+ # remove library test directory
file(REMOVE_RECURSE ${PPC_CHECK_DIR})
if(check_result)
set(PPC_ERROR "Cannot link with standard libraries")
diff --git a/cmake/dists/cmake/Modules/UsePascal.cmake b/cmake/dists/cmake/Modules/UsePascal.cmake
index a67e07b6..e3c3612b 100644
--- a/cmake/dists/cmake/Modules/UsePascal.cmake
+++ b/cmake/dists/cmake/Modules/UsePascal.cmake
@@ -4,25 +4,80 @@
# modification, are permitted in any medium without royalty provided
# the copyright notice and this notice are preserved.
-# - Pascal module build macros
+# - Creates a virtual Pascal package.
+# Do not mix this up with Delphi (dpk), FPC or Lazarus (lpk) packages.
+# A package specified by this command does not define a dll or similar.
+# It is just a compilation of units, includes and object-dirs
+# (mostly used for header files).
+# This information will be appended to a module generated by
+# add_pascal_module() if a package is specified with the PACKAGE
+# option.
+# PASCAL_ADD_PACKAGE(
+# <name>
+# [UNITS file1 [...]]
+# [INCLUDES file1 [...]]
+# [OBJECT_DIRS dir1 [...]]
#
-# ADD_PASCAL_MODULE(
+# - Builds a Pascal module.
+# The module can be a program, library or unit. The type is either autodetected
+# (by the file header) or can be set by the appropriate flag.
+# The output name for executables and libraries (exe, dll, so) will be the
+# name of the target (or the one given by OUTPUT_NAME). It will be located in
+# the current binary dir by default (or in the directory given by OUTPUT_DIR).
+# If main_source is a unit the name of the generated object file (mostly a .o/.ppu pair)
+# will match the units name and located in an extra directory (like i386-linux) in the
+# current binary dir.
+# It is recommended to pass all unit (pas/pp) files and include (inc) files required
+# by the module with the UNITS/INCLUDES flags. Although dependencies are normally
+# already defined in the project file (.lpr/.dpr/...) FPC is not able to reliably track
+# changes in dependencies as it does not search for source-files besides the directory
+# of the project file. When calling FPC directly the user has to pass all paths to source
+# files with the -Fu flag, otherwise FPC will not recompile changed source-files.
+# If you pass all source files (wildcards as dir/*.pas are allowed) with UNITS/INCLUDES
+# pascal_add_module does this for you. In addition the filenames are appended to auto-generated
+# project files for e.g. lazarus.
+# The UNITS/INCLUDES files are also used as dependencies for triggering a rebuild. If REBUILD_ALL
+# is not specified FPC tries to perform a minimal rebuild (only files that changed). If inline
+# functions are used in your project's sources FPC might not be able to perform a minimum rebuild
+# and compiles lots of unchanged units too.
+# (See http://www.mail-archive.com/fpc-devel@lists.freepascal.org/msg11914.html)
+# If for some reason a minimal rebuild fails, specify
+# REBUILD_ALL to recompile all units used by your project.
+# Units/includes used by packages specified by the PACKAGES option do not have to be specified
+# again with UNITS/INCLUDES. Package sources are not appended to auto-generated project files
+# for lazarus.
+# Sets target properties:
+# - PASCAL_TYPE: module type (one of PROGRAM/LIBRARY/UNIT)
+# - PASCAL_LOCATION: full path of output file (equivalent to LOCATION)
+# PASCAL_ADD_MODULE(
# <name>
# [PROGRAM | LIBRARY | UNIT]
-# <source>
-# FLAGS ...
-# DEPENDS depend [...]
-# UNITS file1 [...]
-# INCLUDES file1 [...]
-# OBJECT_DIRS dir1 [...]
-# PACKAGES pkg1 [...]
-# EXCLUDE_FROM_ALL
-# REBUILD_ALL
+# <main_source>
+# [OUTPUT_NAME name]
+# [OUTPUT_DIR dir]
+# [FLAGS ...]
+# [DEPENDS depend [...]]
+# [UNITS file1 [...]]
+# [INCLUDES file1 [...]]
+# [OBJECT_DIRS dir1 [...]]
+# [PACKAGES pkg1 [...]]
+# [EXCLUDE_FROM_ALL]
+# [REBUILD_ALL]
# )
+#
+# - Macro for handling Pascal configuration files
+# Works as configure_file(InputFile OutputFile) but in addition
+# it replaces occurences of {$CMAKEDEFINE(VAR) XYZ} with
+# {$DEFINE XYZ} if the value of VAR is true
+# {$UNDEF XYZ} if the value of VAR is false
+# PASCAL_CONFIGURE_FILE(InputFile OutputFile)
+#
include(MacroParseArguments)
include(LazarusGenerator)
+option(GENERATE_LAZARUS_PROJECTS "Generate lazarus project files (.lpi) for every Pascal target" OFF)
+
function(PASCAL_ADD_PACKAGE name)
set(ARG)
parse_arguments(ARG
@@ -51,7 +106,7 @@ endfunction(PASCAL_ADD_PACKAGE)
macro(PASCAL_ADD_MODULE)
set(ARG)
parse_arguments(ARG
- "FLAGS;DEPENDS;UNITS;INCLUDES;OBJECT_DIRS;PACKAGES"
+ "OUTPUT_NAME;OUTPUT_DIR;FLAGS;DEPENDS;UNITS;INCLUDES;OBJECT_DIRS;PACKAGES"
"EXCLUDE_FROM_ALL;REBUILD_ALL"
${ARGN}
)
@@ -118,18 +173,31 @@ macro(PASCAL_ADD_MODULE)
# init list of additional "make clean" files
set(extra_clean_files "")
- # set ppu and obj output dir
+ # set output directory
+ if(ARG_OUTPUT_DIR)
+ set(output_dir ${ARG_OUTPUT_DIR})
+ else()
+ set(output_dir ${CMAKE_CURRENT_BINARY_DIR})
+ endif()
+
+ # set compiled units (ppu/obj) output directory
set(unit_out_dir ${CMAKE_CURRENT_BINARY_DIR}/${FPC_TARGET})
list(APPEND extra_clean_files ${unit_out_dir})
- # create output name
- set(output_name ${target})
+ # set output-file basename
+ if(ARG_OUTPUT_NAME)
+ set(output_name ${ARG_OUTPUT_NAME})
+ else()
+ set(output_name ${target})
+ endif()
+
+ # create output filename
if(type STREQUAL PROGRAM)
- set(output "${CMAKE_CURRENT_BINARY_DIR}/${output_name}${CMAKE_EXECUTABLE_SUFFIX}")
+ set(output "${output_dir}/${output_name}${CMAKE_EXECUTABLE_SUFFIX}")
list(APPEND extra_clean_files ${output})
endif(type STREQUAL PROGRAM)
if(type STREQUAL LIBRARY)
- set(output "${CMAKE_CURRENT_BINARY_DIR}/${PPC_LIBRARY_PREFIX}${output_name}${PPC_LIBRARY_SUFFIX}")
+ set(output "${output_dir}/${PPC_LIBRARY_PREFIX}${output_name}${PPC_LIBRARY_SUFFIX}")
list(APPEND extra_clean_files ${output})
endif(type STREQUAL LIBRARY)
if(type STREQUAL UNIT)
@@ -228,29 +296,6 @@ macro(PASCAL_ADD_MODULE)
# set flags
list(APPEND PFLAGS ${ARG_FLAGS})
- #-v -l verbose/banner
- #-n ignore fpc.cfg
- #-Fi -I include-dir
- #-k
- #-Fl linker-dir
- #-Fo -Fu object-/unit-dir
- #-Xt -Xc
- #-Ciort range checks
- #-Cs -Ch stack/heap size
- #-Cg -fPIC PIC code
- #-E
- #-g -gv -gw(2/3) -gh -gl -pg
- #-O
- #-T -Xd -XP cross-compiling
- #-d -u define/undefine
- #-Xs strip
- #-B build all modules
- #-Dd -Dv description + DLL-version
-
- #PFLAGS_BASE_DEFAULT := -Si -Sg- -Sc- -v0Binwe
- #PFLAGS_DEBUG_DEFAULT := -Xs- -g -gl -dDEBUG_MODE
- #PFLAGS_RELEASE_DEFAULT := -Xs- -O2
-
# lower-case project type (just for user info)
string(TOLOWER ${type} proj_type_lowcase)
@@ -295,15 +340,32 @@ macro(PASCAL_ADD_MODULE)
# of the target
set_target_properties(${target} PROPERTIES PASCAL_LOCATION ${output})
- generate_lazarus_project(
- ${source}
- ${output}
- ${unit_out_dir}
- "${ARG_UNITS}"
- "${unit_dirs}"
- "${ARG_INCLUDES}"
- "${inc_dirs}"
- "${obj_dirs}"
- "${PFLAGS}"
- )
+ if(GENERATE_LAZARUS_PROJECTS)
+ generate_lazarus_project(
+ ${source}
+ ${output}
+ ${unit_out_dir}
+ "${ARG_UNITS}"
+ "${unit_dirs}"
+ "${ARG_INCLUDES}"
+ "${inc_dirs}"
+ "${obj_dirs}"
+ "${PFLAGS}"
+ )
+ endif(GENERATE_LAZARUS_PROJECTS)
endmacro(PASCAL_ADD_MODULE)
+
+macro(PASCAL_CONFIGURE_FILE)
+ file(READ ${ARGV0} config_file)
+ string(REGEX MATCHALL "{\\$CMAKEDEFINE\\([^\\)]+\\)" pasdefine_list "${config_file}")
+ foreach(pasdefine ${pasdefine_list})
+ string(REGEX REPLACE "{\\$CMAKEDEFINE\\(([^\\)]+)\\)" "\\1" pasdefine_var ${pasdefine})
+ if (${pasdefine_var})
+ string(REPLACE ${pasdefine} "{$DEFINE" config_file "${config_file}")
+ else (${pasdefine_var})
+ string(REPLACE ${pasdefine} "{$UNDEF" config_file "${config_file}")
+ endif (${pasdefine_var})
+ endforeach(pasdefine)
+ string(CONFIGURE "${config_file}" config_file)
+ file(WRITE ${ARGV1} "${config_file}")
+endmacro(PASCAL_CONFIGURE_FILE)