This is the way I like it: 0.9.20
authorunc0rr
Wed, 01 Jan 2014 00:45:28 +0400
branch0.9.20
changeset 9897 f705dc750df2
parent 9895 1f8f7ebf43f7
child 9899 5b8bde62a8ef
This is the way I like it: - Only call fpc on hwengine.pas, let compiler rule the dependencies - Make hwengine.pas depend on all other source files, so 'make' always calls fpc
hedgewars/CMakeLists.txt
--- a/hedgewars/CMakeLists.txt	Tue Dec 31 00:53:29 2013 +0400
+++ b/hedgewars/CMakeLists.txt	Wed Jan 01 00:45:28 2014 +0400
@@ -4,7 +4,8 @@
 find_package(SDL_ttf)
 find_package(SDL_mixer)
 
-include (CheckLibraryExists)
+include(CheckLibraryExists)
+include(${CMAKE_MODULE_PATH}/utils.cmake)
 
 
 enable_language(Pascal)
@@ -83,16 +84,9 @@
 
     #these interact with everything, so compile last
     uScript.pas
-    hwengine.pas
-
-    #we also have uTouch.pas
-    options.inc
-    ${CMAKE_CURRENT_BINARY_DIR}/config.inc
     )
 
 
-include(${CMAKE_MODULE_PATH}/utils.cmake)
-
 if (${CMAKE_Pascal_COMPILER_VERSION} VERSION_LESS 2.2 OR # older versions are just ancient
     (${CMAKE_Pascal_COMPILER_VERSION} VERSION_LESS 2.6 AND APPLE)) # because of 64bit and opengl bindings
     message(FATAL_ERROR "Your FreePascal installation is too old (fpc ${CMAKE_Pascal_COMPILER_VERSION})!")
@@ -171,10 +165,9 @@
 add_definitions(-dDEBUGFILE)
 
 
-# make source files objects depend on their predecessors in list
+# source files are with full path after this
 set(sourcefiles_sofar "${CMAKE_CURRENT_SOURCE_DIR}/options.inc" "${CMAKE_CURRENT_BINARY_DIR}/config.inc")
 foreach(loop_var ${engine_sources})
-    SET_SOURCE_FILES_PROPERTIES(${loop_var} PROPERTIES OBJECT_DEPENDS "${sourcefiles_sofar}")
     list(APPEND sourcefiles_sofar "${CMAKE_CURRENT_SOURCE_DIR}/${loop_var}")
 endforeach(loop_var)
 
@@ -193,12 +186,14 @@
     add_flag_prepend(CMAKE_Pascal_FLAGS "-o${LIBRARY_OUTPUT_PATH}/${engine_output_name}")
 
     add_definitions(-dHWLIBRARY)
-    add_library(hwengine SHARED ${engine_sources} hwLibrary.pas)
+    set_source_files_properties(hwLibrary.pas PROPERTIES OBJECT_DEPENDS "${sourcefiles_sofar}")
+    add_library(hwengine SHARED hwLibrary.pas)
 else()
     # no need to change name here because target has same name
     set(engine_output_name "hwengine${CMAKE_EXECUTABLE_SUFFIX}")
     set(destination_dir ${target_binary_install_dir})
-    add_executable(hwengine ${engine_sources})
+    set_source_files_properties(hwengine.pas PROPERTIES OBJECT_DEPENDS "${sourcefiles_sofar}")
+    add_executable(hwengine hwengine.pas)
 endif()
 
 #even though not actually used, this will trigger relink if any lib changes