better support for cmake directory and fpc output paths cmake_pascal
authorkoda
Mon, 18 Mar 2013 16:38:46 +0100
branchcmake_pascal
changeset 8758 cb3b470f1000
parent 8756 671f6ef4f7f1
child 8761 801cf78707f2
better support for cmake directory and fpc output paths
cmake_modules/CMakePascalCompiler.cmake.in
cmake_modules/CMakePascalInformation.cmake
cmake_modules/CMakeTestPascalCompiler.cmake
--- a/cmake_modules/CMakePascalCompiler.cmake.in	Mon Mar 18 12:30:09 2013 +0100
+++ b/cmake_modules/CMakePascalCompiler.cmake.in	Mon Mar 18 16:38:46 2013 +0100
@@ -7,6 +7,7 @@
 SET(CMAKE_Pascal_COMPILER_ENV_VAR "FPC")
 
 SET(CMAKE_Pascal_SOURCE_FILE_EXTENSIONS "pas" "pp")
-SET(CMAKE_Pascal_IGNORE_EXTENSIONS "o" "ppu" "obj" "def" "rc" "RC")
+SET(CMAKE_Pascal_IGNORE_EXTENSIONS ppu;PPU;h;Ho;O;obj;OBJ;def;DEF;rc;RC)
 SET(CMAKE_Pascal_LINKER_PREFERENCE Prefered)
+SET(CMAKE_Pascal_OUTPUT_EXTENSION_REPLACE 1)
 SET(CMAKE_Pascal_OUTPUT_EXTENSION ".o")
--- a/cmake_modules/CMakePascalInformation.cmake	Mon Mar 18 12:30:09 2013 +0100
+++ b/cmake_modules/CMakePascalInformation.cmake	Mon Mar 18 16:38:46 2013 +0100
@@ -75,9 +75,9 @@
   SET(CMAKE_INCLUDE_FLAG_Pascal ${CMAKE_INCLUDE_FLAG_C})
 ENDIF(NOT CMAKE_INCLUDE_FLAG_Pascal)
 
-#IF(NOT CMAKE_INCLUDE_FLAG_SEP_Ada)
-#  SET(CMAKE_INCLUDE_FLAG_SEP_Ada ${CMAKE_INCLUDE_FLAG_SEP_C})
-#ENDIF(NOT CMAKE_INCLUDE_FLAG_SEP_Ada)
+IF(NOT CMAKE_INCLUDE_FLAG_SEP_Pascal)
+  SET(CMAKE_INCLUDE_FLAG_SEP_Pascal ${CMAKE_INCLUDE_FLAG_SEP_C})
+ENDIF(NOT CMAKE_INCLUDE_FLAG_SEP_Pascal)
 
 # Copy C version of this flag which is normally determined in platform file.
 IF(NOT CMAKE_SHARED_LIBRARY_SONAME_Pascal_FLAG)
@@ -144,7 +144,7 @@
 # compile a Pascal file into an object file
 IF(NOT CMAKE_Pascal_COMPILE_OBJECT)
   SET(CMAKE_Pascal_COMPILE_OBJECT
-      "<CMAKE_Pascal_COMPILER> <FLAGS> <SOURCE> -Cn -FE${EXECUTABLE_OUTPUT_PATH} -FU${CMAKE_CURRENT_BINARY_DIR} -Fi${CMAKE_CURRENT_BINARY_DIR}")
+      "<CMAKE_Pascal_COMPILER> -Cn -FE${EXECUTABLE_OUTPUT_PATH} -FU${CMAKE_CURRENT_BINARY_DIR}/<OBJECT_DIR> -Fi${CMAKE_CURRENT_BINARY_DIR} <FLAGS> <SOURCE>")
 #"<CMAKE_Pascal_COMPILER> <FLAGS> <SOURCE> -o<OBJECT> -Cn
 ENDIF(NOT CMAKE_Pascal_COMPILE_OBJECT)
 
--- a/cmake_modules/CMakeTestPascalCompiler.cmake	Mon Mar 18 12:30:09 2013 +0100
+++ b/cmake_modules/CMakeTestPascalCompiler.cmake	Mon Mar 18 16:38:46 2013 +0100
@@ -1,53 +1,52 @@
 # This file is used by EnableLanguage in cmGlobalGenerator to determine that
-# the Ada builder GNAT_EXECUTABLE_BUILDER = gnatmake can actually compile
-# and link the most basic of programs.  If not, a fatal error is set and
-# cmake stops processing commands and will not generate any makefiles or
-# projects.
+# the FreePascal can actually compile and link the most basic of programs.
+# If not, a fatal error is set, cmake stops processing commands and will not
+# generate any makefiles or projects.
 
 IF(NOT CMAKE_Pascal_COMPILER_WORKS)
   MESSAGE(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER}")
-  FILE(WRITE ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/testpascalcompiler.pas
+  FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/testpascalcompiler.pas
   "program testPascalCompiler;
    begin
    end.
   ")
 
-  FILE(WRITE ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/CMakeLists.txt
+  FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/CMakeLists.txt
   "set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_modules)
    set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL \"\" FORCE)
    project(test Pascal)
    add_executable(testpascalcompiler testpascalcompiler.pas)
   ")
 
-# To avoid try_compile recurse error, use any binary directory other than
-# ${CMAKE_BINARY_DIR}.  The choice of
+# To avoid try_compile recurse error, use any binary directory other
+# than ${CMAKE_BINARY_DIR}. The choice of
 # bindir = ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp is
 # especially advantageous since it makes an in-source build which
 # means that no special variables need to be set to find files.
   try_compile(CMAKE_Pascal_COMPILER_WORKS
-  ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp
-  ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp
-  projectName
-  OUTPUT_VARIABLE OUTPUT
-  )
+              ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp
+              ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp
+              projectName
+              OUTPUT_VARIABLE RESULT_OUTPUT
+              )
   SET(PASCAL_TEST_WAS_RUN 1)
 ENDIF(NOT CMAKE_Pascal_COMPILER_WORKS)
 
 IF(NOT CMAKE_Pascal_COMPILER_WORKS)
   MESSAGE(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER} -- broken")
-  FILE(APPEND ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeError.log
+  FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeError.log
     "Determining if the Pascal compiler works failed with "
-    "the following output:\n${OUTPUT}\n\n")
+    "the following output:\n${RESULT_OUTPUT}\n\n")
   MESSAGE(FATAL_ERROR "The Pascal builder \"${CMAKE_Pascal_COMPILER}\" "
     "is not able to compile and link a simple test program.\nIt fails "
-    "with the following output:\n ${OUTPUT}\n\n"
+    "with the following output:\n ${RESULT_OUTPUT}\n\n"
     "CMake will not be able to correctly generate this project.")
 ELSE(NOT CMAKE_Pascal_COMPILER_WORKS)
   IF(PASCAL_TEST_WAS_RUN)
     MESSAGE(STATUS "Check for working Pascal compiler: ${CMAKE_Pascal_COMPILER} -- works")
-    FILE(APPEND ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+    FILE(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
       "Determining if the Pascal compiler works passed with "
-      "the following output:\n${OUTPUT}\n\n")
+      "the following output:\n${RESULT_OUTPUT}\n\n")
   ENDIF(PASCAL_TEST_WAS_RUN)
   SET(CMAKE_Pascal_COMPILER_WORKS 1 CACHE INTERNAL "")
 ENDIF(NOT CMAKE_Pascal_COMPILER_WORKS)