use target name instead of the resulting library, use more macros around
authorkoda
Thu, 13 Jun 2013 22:50:18 +0200
changeset 9225 d8d929f92633
parent 9224 bce8cf41d666
child 9226 1ac020f959e5
use target name instead of the resulting library, use more macros around
QTfrontend/CMakeLists.txt
cmake_modules/compilerchecks.cmake
cmake_modules/paths.cmake
cmake_modules/utils.cmake
hedgewars/CMakeLists.txt
misc/libphyslayer/CMakeLists.txt
--- a/QTfrontend/CMakeLists.txt	Thu Jun 13 22:27:23 2013 +0200
+++ b/QTfrontend/CMakeLists.txt	Thu Jun 13 22:50:18 2013 +0200
@@ -190,8 +190,7 @@
     )
 
 list(APPEND HW_LINK_LIBS
-    ${PHYSFS_LIBRARY}
-    ${PHYSLAYER_LIBRARY}
+    physfs physlayer
     ${QT_LIBRARIES}
     ${SDL_LIBRARY}
     ${SDLMIXER_LIBRARY}
--- a/cmake_modules/compilerchecks.cmake	Thu Jun 13 22:27:23 2013 +0200
+++ b/cmake_modules/compilerchecks.cmake	Thu Jun 13 22:50:18 2013 +0200
@@ -14,18 +14,18 @@
 #(see 822312 654424 on bugzilla.redhat.com)
 check_c_compiler_flag("-fstack-protector-all -fstack-protector" HAVE_STACKPROTECTOR)
 if(HAVE_STACKPROTECTOR AND (NOT WIN32))
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-all -fstack-protector")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all -fstack-protector")
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fstack-protector-all -fstack-protector")
-    set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -fstack-protector-all -fstack-protector")
-    set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -fstack-protector-all -fstack-protector")
+    add_flag_append(CMAKE_C_FLAGS "-fstack-protector-all -fstack-protector")
+    add_flag_append(CMAKE_CXX_FLAGS "-fstack-protector-all -fstack-protector")
+    add_flag_append(CMAKE_EXE_LINKER_FLAGS "-fstack-protector-all -fstack-protector")
+    add_flag_append(CMAKE_SHARED_LIBRARY_C_FLAGS "-fstack-protector-all -fstack-protector")
+    add_flag_append(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fstack-protector-all -fstack-protector")
 endif()
 
 #symbol visibility, not supported on Windows
 check_c_compiler_flag("-fvisibility=hidden" HAVE_VISIBILITY)
 if(HAVE_VISIBILITY AND (NOT WIN32))
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
+    add_flag_append(CMAKE_C_FLAGS "-fvisibility=hidden")
+    add_flag_append(CMAKE_CXX_FLAGS "-fvisibility=hidden")
 endif()
 
 
@@ -33,21 +33,21 @@
 set(CMAKE_REQUIRED_FLAGS "-Wl,-z,noexecstack")
 check_c_compiler_flag("" HAVE_NOEXECSTACK)
 if(HAVE_NOEXECSTACK)
-    append_linker_flag("-znoexecstack")
+    add_linker_flag("-znoexecstack")
 endif()
 
 #check for full relro on ELF, Debian security
 set(CMAKE_REQUIRED_FLAGS "-Wl,-zrelro,-znow")
 check_c_compiler_flag("" HAVE_RELROFULL)
 if(HAVE_RELROFULL)
-    append_linker_flag("-zrelro")
-    append_linker_flag("-znow")
+    add_linker_flag("-zrelro")
+    add_linker_flag("-znow")
 else()
     #if full relro is not available, try partial relro
     set(CMAKE_REQUIRED_FLAGS "-Wl,-zrelro")
     check_c_compiler_flag("" HAVE_RELROPARTIAL)
     if(HAVE_RELROPARTIAL)
-        append_linker_flag("-zrelro")
+        add_linker_flag("-zrelro")
     endif()
 endif()
 
@@ -55,21 +55,21 @@
 set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat")
 check_c_compiler_flag("" HAVE_WINASLR)
 if(HAVE_WINASLR)
-    append_linker_flag("--nxcompat")
+    add_linker_flag("--nxcompat")
 endif()
 
 #check for DEP on Windows XP SP2 or later, requires binutils >= 2.20
 set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase")
 check_c_compiler_flag("" HAVE_WINDEP)
 if(HAVE_WINDEP)
-    append_linker_flag("--dynamicbase")
+    add_linker_flag("--dynamicbase")
 endif()
 
 #this is actually an optimisation
 set(CMAKE_REQUIRED_FLAGS "-Wl,--as-needed")
 check_c_compiler_flag("" HAVE_ASNEEDED)
 if(HAVE_ASNEEDED)
-    append_linker_flag("--as-needed")
+    add_linker_flag("--as-needed")
 endif()
 
 #always unset or these flags will be spread everywhere
--- a/cmake_modules/paths.cmake	Thu Jun 13 22:27:23 2013 +0200
+++ b/cmake_modules/paths.cmake	Thu Jun 13 22:50:18 2013 +0200
@@ -63,7 +63,7 @@
     #make sure $ORIGIN is respected
     append_linker_flag("-zorigin")
     #apply RPATH settings to pascal and haskell executables
-    list(APPEND pascal_flags "-k-rpath" "-k'${CMAKE_INSTALL_RPATH_ESCAPED}'")
+    add_flag_append(CMAKE_Pascal_FLAGS "-k-rpath '${CMAKE_INSTALL_RPATH_ESCAPED}'")
     list(APPEND haskell_flags "-optl" "-Wl,-rpath,'${CMAKE_INSTALL_RPATH_ESCAPED}'")
 endif()
 
--- a/cmake_modules/utils.cmake	Thu Jun 13 22:27:23 2013 +0200
+++ b/cmake_modules/utils.cmake	Thu Jun 13 22:50:18 2013 +0200
@@ -1,4 +1,5 @@
 
+#find package helpers
 macro(find_package_or_fail _PKG_NAME)
     find_package(${_PKG_NAME})
     string(TOUPPER ${_PKG_NAME} _PKG_NAME_UP)
@@ -25,17 +26,7 @@
     endif(NOT ${_VAR_NAME})
 endmacro(find_package_or_disable_msg _PKG_NAME _VAR_NAME _MSG)
 
-macro(append_linker_flag _FLAG)
-    list(APPEND pascal_flags "-k${_FLAG}")
-    list(APPEND haskell_flags "-optl" "${_FLAG}")
-    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,${_FLAG}")
-    set(CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS} -Wl,${_FLAG}")
-    set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CXX_FLAGS} -Wl,${_FLAG}")
-endmacro(append_linker_flag _FLAG)
-
-#TODO: find_package_or_bundle
-
-
+#variable manipulation macros
 macro(add_flag_append _VAR_NAME _FLAG)
     set(${_VAR_NAME} "${${_VAR_NAME}} ${_FLAG}")
 endmacro(add_flag_append _VAR_NAME _FLAG)
@@ -44,3 +35,15 @@
     set(${_VAR_NAME} "${_FLAG} ${${_VAR_NAME}}")
 endmacro(add_flag_prepend _VAR_NAME _FLAG)
 
+macro(add_linker_flag _FLAG)
+    list(APPEND haskell_flags "-optl" "${_FLAG}")
+    add_flag_prepend(CMAKE_Pascal_FLAGS "-k${_FLAG}")
+    add_flag_prepend(CMAKE_EXE_LINKER_FLAGS "-Wl,${_FLAG}")
+    add_flag_prepend(CMAKE_SHARED_LIBRARY_C_FLAGS "-Wl,${_FLAG}")
+    add_flag_prepend(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-Wl,${_FLAG}")
+endmacro(add_linker_flag _FLAG)
+
+#TODO: find_package_or_bundle
+
+
+
--- a/hedgewars/CMakeLists.txt	Thu Jun 13 22:27:23 2013 +0200
+++ b/hedgewars/CMakeLists.txt	Thu Jun 13 22:50:18 2013 +0200
@@ -81,10 +81,6 @@
     ${CMAKE_CURRENT_BINARY_DIR}/config.inc
     )
 
-if(${BUILD_ENGINE_LIBRARY})
-    message("*** Engine will be built as library (experimental) ***")
-    list(APPEND pascal_flags "-dHWLIBRARY")
-endif()
 
 include(${CMAKE_MODULE_PATH}/utils.cmake)
 
@@ -146,18 +142,16 @@
 if(PNG_FOUND)
     list(REMOVE_AT PNG_LIBRARIES 1) #removing the zlib library path
     get_filename_component(PNG_LIBRARY_DIR ${PNG_LIBRARIES} PATH)
-    list(APPEND pascal_flags "-dPNG_SCREENSHOTS" "-Fl${PNG_LIBRARY_DIR}" "-k-L${PNG_LIBRARY_DIR}")
+    add_flag_append(CMAKE_Pascal_FLAGS -Fl${PNG_LIB_DIR})
 endif()
 
 if(LUA_FOUND AND LUA_SYSTEM)
+    list(APPEND HW_LINK_LIBS lua)
     get_filename_component(LUA_LIBRARY_DIR ${LUA_LIBRARY} PATH)
     get_filename_component(LUA_LIBRARY_NAME ${LUA_LIBRARY} NAME)
     #NAME_WE would strip the .1 (or .2) next to the ".so"
     string(REGEX REPLACE "${CMAKE_SHARED_LIBRARY_PREFIX}(.*)${CMAKE_SHARED_LIBRARY_SUFFIX}" "\\1" LUA_LIBRARY_NAME "${LUA_LIBRARY_NAME}")
-    list(APPEND pascal_flags )
-    list(APPEND pascal_flags "-Fl${LUA_LIBRARY_DIR}"
-                             "-k-L${LUA_LIBRARY_DIR}"
-                             "-XLAlua=${LUA_LIBRARY_NAME}")
+    add_flag_append(CMAKE_Pascal_FLAGS "-Fl${LUA_LIBRARY_DIR} -k-L${LUA_LIBRARY_DIR} -XLAlua=${LUA_LIBRARY_NAME}")
 endif()
 
 
--- a/misc/libphyslayer/CMakeLists.txt	Thu Jun 13 22:27:23 2013 +0200
+++ b/misc/libphyslayer/CMakeLists.txt	Thu Jun 13 22:50:18 2013 +0200
@@ -15,7 +15,7 @@
 #compiles and links actual library
 add_library (physlayer ${PHYSLAYER_SRCS})
 #TODO: find good VERSION and SOVERSION values
-target_link_libraries(physlayer ${SDL_LIBRARY} ${LUA_LIBRARY} ${PHYSFS_LIBRARY})
+target_link_libraries(physlayer ${SDL_LIBRARY} lua physfs)
 install(TARGETS physlayer RUNTIME DESTINATION ${target_binary_install_dir}
                           LIBRARY DESTINATION ${target_library_install_dir}
                           ARCHIVE DESTINATION ${target_library_install_dir})