with lot of hackery, use add_executable on pascal files, SUCCSS cmake_pascal
authorkoda
Mon, 18 Mar 2013 02:07:58 +0100
branchcmake_pascal
changeset 8752 48cf2ccb83c6
parent 8750 d9e57426e759
child 8754 0c08d07e791a
with lot of hackery, use add_executable on pascal files, SUCCSS
cmake_modules/CMakeDeterminePascalCompiler.cmake
cmake_modules/CMakePascalInformation.cmake
cmake_modules/CMakeTestPascalCompiler.cmake
hedgewars/CMakeLists.txt
--- a/cmake_modules/CMakeDeterminePascalCompiler.cmake	Mon Mar 18 00:58:13 2013 +0100
+++ b/cmake_modules/CMakeDeterminePascalCompiler.cmake	Mon Mar 18 02:07:58 2013 +0100
@@ -1,7 +1,7 @@
 # Determine the compiler to use for Pascal programs
 # NOTE, a generator may set CMAKE_Pascal_COMPILER before
 # loading this file to force a compiler.
-# use environment variable Pascal first if defined by user, next use 
+# use environment variable Pascal first if defined by user, next use
 # the cmake variable CMAKE_GENERATOR_PASCAL which can be defined by a generator
 # as a default compiler
 
@@ -15,12 +15,12 @@
     ENDIF(CMAKE_Pascal_FLAGS_ENV_INIT)
     IF(EXISTS ${CMAKE_Pascal_COMPILER_INIT})
     ELSE(EXISTS ${CMAKE_Pascal_COMPILER_INIT})
-      MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable FPC:\n$ENV{FPC}.") 
+      MESSAGE(FATAL_ERROR "Could not find compiler set in environment variable FPC:\n$ENV{FPC}.")
     ENDIF(EXISTS ${CMAKE_Pascal_COMPILER_INIT})
   ENDIF($ENV{FPC} MATCHES ".+")
 
   # next try prefer the compiler specified by the generator
-  IF(CMAKE_GENERATOR_PASCAL) 
+  IF(CMAKE_GENERATOR_PASCAL)
     IF(NOT CMAKE_Pascal_COMPILER_INIT)
       SET(CMAKE_Pascal_COMPILER_INIT ${CMAKE_GENERATOR_PASCAL})
     ENDIF(NOT CMAKE_Pascal_COMPILER_INIT)
@@ -30,7 +30,7 @@
   IF(CMAKE_Pascal_COMPILER_INIT)
     SET(CMAKE_Pascal_COMPILER_LIST ${CMAKE_Pascal_COMPILER_INIT})
   ELSE(CMAKE_Pascal_COMPILER_INIT)
-    SET(CMAKE_Pascal_COMPILER_LIST fpc ppc386 ppcx64 ppcppc ppcarm)  
+    SET(CMAKE_Pascal_COMPILER_LIST fpc)
   ENDIF(CMAKE_Pascal_COMPILER_INIT)
 
   # Find the compiler.
@@ -53,8 +53,8 @@
 MARK_AS_ADVANCED(CMAKE_RANLIB)
 
 # configure variables set in this file for fast reload later on
-#CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakePascalCompiler.cmake.in 
-CONFIGURE_FILE(${CMAKE_MODULE_PATH}/CMakePascalCompiler.cmake.in 
+#CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakePascalCompiler.cmake.in
+CONFIGURE_FILE(${CMAKE_MODULE_PATH}/CMakePascalCompiler.cmake.in
                "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/${CMAKE_VERSION}/CMakePascalCompiler.cmake"
                IMMEDIATE)
 MARK_AS_ADVANCED(CMAKE_AR)
--- a/cmake_modules/CMakePascalInformation.cmake	Mon Mar 18 00:58:13 2013 +0100
+++ b/cmake_modules/CMakePascalInformation.cmake	Mon Mar 18 02:07:58 2013 +0100
@@ -8,7 +8,7 @@
 INCLUDE(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME} OPTIONAL)
 
 # This should be included before the _INIT variables are
-# used to initialize the cache.  Since the rule variables 
+# used to initialize the cache.  Since the rule variables
 # have if blocks on them, users can still define them here.
 # But, it should still be after the platform file so changes can
 # be made to those values.
@@ -46,7 +46,7 @@
 #ENDIF(NOT CMAKE_SHARED_LIBRARY_LINK_Ada_FLAGS)
 
 #IF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG)
-#  SET(CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG}) 
+#  SET(CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG ${CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG})
 #ENDIF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG)
 
 #IF(NOT CMAKE_SHARED_LIBRARY_RUNTIME_Ada_FLAG_SEP)
@@ -63,7 +63,7 @@
 #ENDIF(NOT CMAKE_SHARED_MODULE_Ada_FLAGS)
 
 #IF(NOT CMAKE_SHARED_MODULE_RUNTIME_Ada_FLAG)
-#  SET(CMAKE_SHARED_MODULE_RUNTIME_Ada_FLAG ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG}) 
+#  SET(CMAKE_SHARED_MODULE_RUNTIME_Ada_FLAG ${CMAKE_SHARED_MODULE_RUNTIME_C_FLAG})
 #ENDIF(NOT CMAKE_SHARED_MODULE_RUNTIME_Ada_FLAG)
 
 #IF(NOT CMAKE_SHARED_MODULE_RUNTIME_Ada_FLAG_SEP)
@@ -86,7 +86,7 @@
 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.")
 
 SET (CMAKE_Pascal_FLAGS "$ENV{FPFLAGS} ${CMAKE_Pascal_FLAGS_INIT}" CACHE STRING
-     "Flags for Ada compiler.")
+     "Flags for Pascal compiler.")
 
 INCLUDE(CMakeCommonLanguageInclude)
 
@@ -108,13 +108,13 @@
 # <LINK_FLAGS>
 
 # Ada compiler information
-# <CMAKE_Ada_COMPILER>  
+# <CMAKE_Ada_COMPILER>
 # <CMAKE_SHARED_LIBRARY_CREATE_Ada_FLAGS>
 # <CMAKE_SHARED_MODULE_CREATE_Ada_FLAGS>
 # <CMAKE_Ada_LINK_FLAGS>
 
 # Static library tools
-# <CMAKE_AR> 
+# <CMAKE_AR>
 # <CMAKE_RANLIB>
 
 
@@ -156,7 +156,7 @@
 # routine qualifies since it is normally small.  Thus, the normal usage is
 # add_executable(foo foo.adb), but  add_executable(foo path/minimal.adb) would
 # work as well so long as both path/minimal.adb existed and foo.adb existed.
-# Also, note there is no way to specify 
+# Also, note there is no way to specify
 # ${CMAKE_CURRENT_SOURCE_DIR}/<TARGET>.adb as the code for gnatmake to compile
 # because in this context ${CMAKE_CURRENT_SOURCE_DIR} is set to the top
 # of the source tree and not the expected sub-directory of the source tree.
@@ -168,13 +168,14 @@
 # In sum, you have to be careful of your target name, the nominal source file
 # name has to be compilable, but otherwise it is ignored, and you must specify
 # the required -aI and other GNAT_EXECUTABLE_BUILDER = gnatmake options
-# using LINK_FLAGS specified with set_target_properties.  
+# using LINK_FLAGS specified with set_target_properties.
 # However, so long as you pay attention to these
 # constraints, add_executable should work for the Ada language.
 
 IF(NOT CMAKE_Pascal_LINK_EXECUTABLE)
 #GET_FILENAME_COMPONENT(COMPILER_LOCATION "${CMAKE_Pascal_COMPILER}" PATH)
-    set(CMAKE_Pascal_LINK_EXECUTABLE "${CMAKE_BINARY_DIR}/ppas.sh")
+    message("look here ${CMAKE_CURRENT_BINARY_DIR}")
+    set(CMAKE_Pascal_LINK_EXECUTABLE "${EXECUTABLE_OUTPUT_PATH}/ppas.sh")
 #  SET(CMAKE_Pascal_LINK_EXECUTABLE "${CMAKE_Pascal_COMPILER} <CMAKE_Ada_LINK_FLAGS> <LINK_FLAGS> <TARGET_BASE>.adb -cargs <FLAGS> -largs <LINK_LIBRARIES>")
 ENDIF(NOT CMAKE_Pascal_LINK_EXECUTABLE)
 
--- a/cmake_modules/CMakeTestPascalCompiler.cmake	Mon Mar 18 00:58:13 2013 +0100
+++ b/cmake_modules/CMakeTestPascalCompiler.cmake	Mon Mar 18 02:07:58 2013 +0100
@@ -36,19 +36,19 @@
 
 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_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeError.log
     "Determining if the Pascal compiler works failed with "
     "the following output:\n${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 "
+    "is not able to compile and link a simple test program.\nIt fails "
     "with the following output:\n ${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_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${OUTPUT}\n\n")
   ENDIF(PASCAL_TEST_WAS_RUN)
   SET(CMAKE_Pascal_COMPILER_WORKS 1 CACHE INTERNAL "")
 ENDIF(NOT CMAKE_Pascal_COMPILER_WORKS)
--- a/hedgewars/CMakeLists.txt	Mon Mar 18 00:58:13 2013 +0100
+++ b/hedgewars/CMakeLists.txt	Mon Mar 18 02:07:58 2013 +0100
@@ -17,16 +17,17 @@
 endif()
 
 
+enable_language(Pascal)
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.inc.in ${CMAKE_CURRENT_BINARY_DIR}/config.inc)
 
 #SOURCE AND PROGRAMS SECTION
-if(${BUILD_ENGINE_LIBRARY})
-    set(engine_output_name "${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}")
-    set(hwengine_project hwLibrary.pas)
-else()
-    set(engine_output_name "hwengine${CMAKE_EXECUTABLE_SUFFIX}")
-    set(hwengine_project hwengine.pas)
-endif()
+#if(${BUILD_ENGINE_LIBRARY})
+#    set(engine_output_name "${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}")
+#    set(hwengine_project hwLibrary.pas)
+#else()
+#    set(engine_output_name "hwengine${CMAKE_EXECUTABLE_SUFFIX}")
+#    set(hwengine_project hwengine.pas)
+#endif()
 
 if (APPLE)
     set(required_fpc_version 2.6)
@@ -203,43 +204,12 @@
 endif()
 
 
+set(CMAKE_Pascal_FLAGS "-B -FE${PROJECT_BINARY_DIR}/bin -FU${PROJECT_BINARY_DIR}/hedgewars -vm4079,4080,4081 -Fl${PROJECT_BINARY_DIR}/bin -Px86_64   -Fi${PROJECT_BINARY_DIR}/hedgewars -k-L${PROJECT_BINARY_DIR}/bin -Cs2000000 -vewnq -dDEBUGFILE -k-llua -k${SDLMAIN_LIB}")
+add_executable(hwengine hwengine.pas)
+
 set(fpc_flags ${pascal_flags} ${hwengine_project})
 
-if(NOT APPLE)
-    #here is the command for standard executables or for shared library
-    add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}"
-        COMMAND "${FREEPASCAL_EXECUTABLE}"
-        ARGS ${fpc_flags} -o${engine_output_name}
-        DEPENDS ${engine_sources}
-        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-        )
-else()
-    #these are the dependencies for building a universal binary on Mac OS X
-    foreach (build_arch ${powerpc_build} ${i386_build} ${x86_64_build})
-        list(APPEND lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}")
-        add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}"
-            COMMAND "${FREEPASCAL_EXECUTABLE}"
-            ARGS ${fpc_flags} -ohwengine.${build_arch} -P${build_arch}
-            DEPENDS ${engine_sources}
-            WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-            )
-        add_custom_target(hwengine.${build_arch} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}")
-        add_custom_command(TARGET hwengine.${build_arch} POST_BUILD
-            COMMAND "install_name_tool"
-            ARGS -id @executable_path/../Frameworks/${engine_output_name}
-                ${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}
-            )
-    endforeach()
-
-    add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}"
-        COMMAND "lipo"
-        ARGS ${lipo_args_list} -create -output ${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}
-        DEPENDS ${lipo_args_list}
-        )
-endif()
-
-
-add_custom_target(hwengine ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}")
+#add_custom_target(hwengine ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}")
 
 #when system Lua is not found we need to compile it before engine
 if(NOT LUA_FOUND)
@@ -264,4 +234,4 @@
     add_dependencies(hwengine ENGINECLEAN)
 endif()
 
-install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}" DESTINATION ${destination_dir})
+install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/hwengine" DESTINATION ${destination_dir})