Improved unix compiler flag settings to keep user settings, qrc and translation handling, 64 bit defines
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@323 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -81,6 +81,15 @@ else ()
|
|||||||
set (ACG_PROJECT_BINDIR "bin")
|
set (ACG_PROJECT_BINDIR "bin")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if( NOT APPLE )
|
||||||
|
# check 64 bit
|
||||||
|
if( CMAKE_SIZEOF_VOID_P MATCHES 4 )
|
||||||
|
set( HAVE_64_BIT 0 )
|
||||||
|
else( CMAKE_SIZEOF_VOID_P MATCHES 4 )
|
||||||
|
set( HAVE_64_BIT 1 )
|
||||||
|
endif( CMAKE_SIZEOF_VOID_P MATCHES 4 )
|
||||||
|
endif ( NOT APPLE )
|
||||||
|
|
||||||
# allow a project to modify the directories
|
# allow a project to modify the directories
|
||||||
if (COMMAND acg_modify_project_dirs)
|
if (COMMAND acg_modify_project_dirs)
|
||||||
acg_modify_project_dirs ()
|
acg_modify_project_dirs ()
|
||||||
@@ -108,6 +117,7 @@ macro (acg_set_target_props target)
|
|||||||
SKIP_BUILD_RPATH 0
|
SKIP_BUILD_RPATH 0
|
||||||
)
|
)
|
||||||
elseif (NOT APPLE)
|
elseif (NOT APPLE)
|
||||||
|
|
||||||
set_target_properties (
|
set_target_properties (
|
||||||
${target} PROPERTIES
|
${target} PROPERTIES
|
||||||
INSTALL_RPATH "$ORIGIN/../lib/${CMAKE_PROJECT_NAME}"
|
INSTALL_RPATH "$ORIGIN/../lib/${CMAKE_PROJECT_NAME}"
|
||||||
@@ -282,6 +292,36 @@ macro (acg_qt4_autouic uic_SRCS)
|
|||||||
endforeach ()
|
endforeach ()
|
||||||
endmacro ()
|
endmacro ()
|
||||||
|
|
||||||
|
|
||||||
|
# generate qrc targets for sources in list
|
||||||
|
macro (acg_qt4_autoqrc qrc_SRCS)
|
||||||
|
|
||||||
|
set (_matching_FILES )
|
||||||
|
foreach (_current_FILE ${ARGN})
|
||||||
|
|
||||||
|
get_filename_component (_abs_FILE ${_current_FILE} ABSOLUTE)
|
||||||
|
|
||||||
|
if ( EXISTS ${_abs_FILE} )
|
||||||
|
|
||||||
|
file (READ ${_abs_FILE} _contents)
|
||||||
|
|
||||||
|
get_filename_component (_abs_PATH ${_abs_FILE} PATH)
|
||||||
|
|
||||||
|
get_filename_component (_basename ${_current_FILE} NAME_WE)
|
||||||
|
set (_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${_basename}.cpp)
|
||||||
|
|
||||||
|
add_custom_command (OUTPUT ${_outfile}
|
||||||
|
COMMAND ${QT_RCC_EXECUTABLE}
|
||||||
|
ARGS -o ${_outfile} ${_abs_FILE}
|
||||||
|
DEPENDS ${_abs_FILE})
|
||||||
|
|
||||||
|
add_file_dependencies (${_source} ${_outfile})
|
||||||
|
set (${qrc_SRCS} ${${qrc_SRCS}} ${_outfile})
|
||||||
|
|
||||||
|
endif ()
|
||||||
|
endforeach ()
|
||||||
|
endmacro ()
|
||||||
|
|
||||||
# get all files in directory, but ignore svn
|
# get all files in directory, but ignore svn
|
||||||
macro (acg_get_files_in_dir ret dir)
|
macro (acg_get_files_in_dir ret dir)
|
||||||
file (GLOB_RECURSE __files RELATIVE "${dir}" "${dir}/*")
|
file (GLOB_RECURSE __files RELATIVE "${dir}" "${dir}/*")
|
||||||
@@ -459,4 +499,60 @@ function (acg_add_library _target _libtype)
|
|||||||
install (TARGETS ${_target} DESTINATION ${ACG_PROJECT_PLUGINDIR})
|
install (TARGETS ${_target} DESTINATION ${ACG_PROJECT_PLUGINDIR})
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
endfunction ()
|
||||||
|
|
||||||
|
#generates qt translations
|
||||||
|
function (acg_add_translations _target _languages _sources)
|
||||||
|
|
||||||
|
string (TOUPPER ${_target} _TARGET)
|
||||||
|
# generate/use translation files
|
||||||
|
# run with UPDATE_TRANSLATIONS set to on to build qm files
|
||||||
|
option (UPDATE_TRANSLATIONS_${_TARGET} "Update source translation *.ts files (WARNING: make clean will delete the source .ts files! Danger!)")
|
||||||
|
|
||||||
|
set (_new_ts_files)
|
||||||
|
set (_ts_files)
|
||||||
|
|
||||||
|
foreach (lang ${_languages})
|
||||||
|
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/translations/${_target}_${lang}.ts" OR UPDATE_TRANSLATIONS_${_TARGET})
|
||||||
|
list (APPEND _new_ts_files "translations/${_target}_${lang}.ts")
|
||||||
|
else ()
|
||||||
|
list (APPEND _ts_files "translations/${_target}_${lang}.ts")
|
||||||
|
endif ()
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
|
||||||
|
set (_qm_files)
|
||||||
|
if ( _new_ts_files )
|
||||||
|
qt4_create_translation(_qm_files ${_sources} ${_new_ts_files})
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if ( _ts_files )
|
||||||
|
qt4_add_translation(_qm_files2 ${_ts_files})
|
||||||
|
list (APPEND _qm_files ${_qm_files2})
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# create a target for the translation files ( and object files )
|
||||||
|
# Use this target, to update only the translations
|
||||||
|
add_custom_target (translations_target_${_target} DEPENDS ${_qm_files})
|
||||||
|
|
||||||
|
# Build translations with the application
|
||||||
|
add_dependencies(${_target} translations_target_${_target} )
|
||||||
|
|
||||||
|
if (NOT EXISTS ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Translations)
|
||||||
|
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Translations )
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
foreach (_qm ${_qm_files})
|
||||||
|
get_filename_component (_qm_name "${_qm}" NAME)
|
||||||
|
add_custom_command (TARGET translations_target_${_target} POST_BUILD
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E
|
||||||
|
copy_if_different
|
||||||
|
${_qm}
|
||||||
|
${CMAKE_BINARY_DIR}/Build/${ACG_PROJECT_DATADIR}/Translations/${_qm_name})
|
||||||
|
endforeach ()
|
||||||
|
|
||||||
|
if (NOT ACG_PROJECT_MACOS_BUNDLE OR NOT APPLE)
|
||||||
|
install (FILES ${_qm_files} DESTINATION "${ACG_PROJECT_DATADIR}/Translations")
|
||||||
|
endif ()
|
||||||
endfunction ()
|
endfunction ()
|
||||||
|
|||||||
@@ -4,14 +4,148 @@
|
|||||||
|
|
||||||
if (UNIX)
|
if (UNIX)
|
||||||
|
|
||||||
set (CMAKE_CFLAGS_RELEASE "-O3 -DINCLUDE_TEMPLATES -W -Wall -Wno-unused -DNDEBUG")
|
set ( ADDITIONAL_CXX_DEBUG_FLAGS )
|
||||||
set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DINCLUDE_TEMPLATES -ftemplate-depth-100 -W -Wall -Wno-unused -DNDEBUG")
|
set ( ADDITIONAL_CXX_RELEASE_FLAGS )
|
||||||
set (CMAKE_C_FLAGS_DEBUG "-g -DINCLUDE_TEMPLATES -W -Wall -Wno-unused -DDEBUG")
|
set ( ADDITIONAL_CXX_RELWITHDEBINFO_FLAGS )
|
||||||
set (CMAKE_CXX_FLAGS_DEBUG "-g -DINCLUDE_TEMPLATES -ftemplate-depth-100 -W -Wall -Wno-unused -DDEBUG")
|
|
||||||
|
set ( ADDITIONAL_C_DEBUG_FLAGS )
|
||||||
|
set ( ADDITIONAL_C_RELEASE_FLAGS )
|
||||||
|
set ( ADDITIONAL_C_RELWITHDEBINFO_FLAGS )
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Defaults
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# add our standard flags for Template inclusion
|
||||||
|
list(APPEND ADDITIONAL_CXX_DEBUG_FLAGS "-DINCLUDE_TEMPLATES" )
|
||||||
|
list(APPEND ADDITIONAL_CXX_RELEASE_FLAGS "-DINCLUDE_TEMPLATES" )
|
||||||
|
list(APPEND ADDITIONAL_CXX_RELWITHDEBINFO_FLAGS "-DINCLUDE_TEMPLATES" )
|
||||||
|
|
||||||
|
# add our standard flags for Template inclusion
|
||||||
|
list(APPEND ADDITIONAL_C_DEBUG_FLAGS "-DINCLUDE_TEMPLATES" )
|
||||||
|
list(APPEND ADDITIONAL_C_RELEASE_FLAGS "-DINCLUDE_TEMPLATES" )
|
||||||
|
list(APPEND ADDITIONAL_C_RELWITHDEBINFO_FLAGS "-DINCLUDE_TEMPLATES" )
|
||||||
|
|
||||||
|
# Increase the template depth as this might be exceeded from time to time
|
||||||
|
IF( NOT CMAKE_SYSTEM MATCHES "SunOS*")
|
||||||
|
list(APPEND ADDITIONAL_CXX_DEBUG_FLAGS "-ftemplate-depth-100" )
|
||||||
|
list(APPEND ADDITIONAL_CXX_RELEASE_FLAGS "-ftemplate-depth-100" )
|
||||||
|
list(APPEND ADDITIONAL_CXX_RELWITHDEBINFO_FLAGS "-ftemplate-depth-100" )
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# OS Defines
|
||||||
|
################################################################################
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
add_definitions( -DARCH_DARWIN )
|
add_definitions( -DARCH_DARWIN )
|
||||||
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-non-virtual-dtor")
|
|
||||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-non-virtual-dtor")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Build/Release Defines
|
||||||
|
################################################################################
|
||||||
|
IF( NOT CMAKE_SYSTEM MATCHES "SunOS*")
|
||||||
|
list(APPEND ADDITIONAL_CXX_DEBUG_FLAGS "-DDEBUG" )
|
||||||
|
list(APPEND ADDITIONAL_CXX_RELEASE_FLAGS "-DNDEBUG" )
|
||||||
|
list(APPEND ADDITIONAL_CXX_RELWITHDEBINFO_FLAGS "-DDEBUG" )
|
||||||
|
|
||||||
|
list(APPEND ADDITIONAL_C_DEBUG_FLAGS "-DDEBUG" )
|
||||||
|
list(APPEND ADDITIONAL_C_RELEASE_FLAGS "-DNDEBUG" )
|
||||||
|
list(APPEND ADDITIONAL_C_RELWITHDEBINFO_FLAGS "-DDEBUG" )
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Warnings
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
IF( NOT CMAKE_SYSTEM MATCHES "SunOS*")
|
||||||
|
list(APPEND ADDITIONAL_CXX_DEBUG_FLAGS "-W" "-Wall" "-Wno-unused" )
|
||||||
|
list(APPEND ADDITIONAL_CXX_RELEASE_FLAGS "-W" "-Wall" "-Wno-unused" )
|
||||||
|
list(APPEND ADDITIONAL_CXX_RELWITHDEBINFO_FLAGS "-W" "-Wall" "-Wno-unused" )
|
||||||
|
|
||||||
|
list(APPEND ADDITIONAL_C_DEBUG_FLAGS "-W" "-Wall" "-Wno-unused" )
|
||||||
|
list(APPEND ADDITIONAL_C_RELEASE_FLAGS "-W" "-Wall" "-Wno-unused" )
|
||||||
|
list(APPEND ADDITIONAL_C_RELWITHDEBINFO_FLAGS "-W" "-Wall" "-Wno-unused" )
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
if (APPLE)
|
||||||
|
list(APPEND ADDITIONAL_CXX_DEBUG_FLAGS "-Wno-non-virtual-dtor" )
|
||||||
|
list(APPEND ADDITIONAL_CXX_RELEASE_FLAGS "-Wno-non-virtual-dtor" )
|
||||||
|
list(APPEND ADDITIONAL_CXX_RELWITHDEBINFO_FLAGS "-Wno-non-virtual-dtor" )
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# STL Vector checks
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Pre initialize stl vector check variable
|
||||||
|
if ( NOT STL_VECTOR_CHECKS )
|
||||||
|
set ( STL_VECTOR_CHECKS false CACHE BOOL "Include full stl vector checks in debug mode (This option is only used in debug Mode!)" )
|
||||||
|
endif ( NOT STL_VECTOR_CHECKS )
|
||||||
|
|
||||||
|
# Add a flag to check stl vectors in debugging mode
|
||||||
|
if ( STL_VECTOR_CHECKS AND NOT CMAKE_SYSTEM MATCHES "SunOS*" )
|
||||||
|
list(APPEND ADDITIONAL_CXX_DEBUG_FLAGS "-D_GLIBCXX_DEBUG" )
|
||||||
|
list(APPEND ADDITIONAL_CXX_DEBUG_FLAGS "-D_GLIBCXX_DEBUG_PEDANTIC")
|
||||||
|
list(APPEND ADDITIONAL_CXX_RELWITHDEBINFO_FLAGS "-D_GLIBCXX_DEBUG" )
|
||||||
|
list(APPEND ADDITIONAL_CXX_RELWITHDEBINFO_FLAGS "-D_GLIBCXX_DEBUG_PEDANTIC")
|
||||||
|
|
||||||
|
list(APPEND ADDITIONAL_C_DEBUG_FLAGS "-D_GLIBCXX_DEBUG" )
|
||||||
|
list(APPEND ADDITIONAL_C_DEBUG_FLAGS "-D_GLIBCXX_DEBUG_PEDANTIC")
|
||||||
|
list(APPEND ADDITIONAL_C_RELWITHDEBINFO_FLAGS "-D_GLIBCXX_DEBUG" )
|
||||||
|
list(APPEND ADDITIONAL_C_RELWITHDEBINFO_FLAGS "-D_GLIBCXX_DEBUG_PEDANTIC")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Process the additional flags:
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Add the debug flags
|
||||||
|
foreach( flag ${ADDITIONAL_CXX_DEBUG_FLAGS} )
|
||||||
|
if( NOT CMAKE_CXX_FLAGS_DEBUG MATCHES "${flag}" )
|
||||||
|
set( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${flag} ")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Add the release flags
|
||||||
|
foreach( flag ${ADDITIONAL_CXX_RELEASE_FLAGS} )
|
||||||
|
if( NOT CMAKE_CXX_FLAGS_RELEASE MATCHES "${flag}" )
|
||||||
|
set( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${flag} ")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Add the release with debug info flags
|
||||||
|
foreach( flag ${ADDITIONAL_CXX_RELWITHDEBINFO_FLAGS} )
|
||||||
|
if( NOT CMAKE_CXX_FLAGS_RELWITHDEBINFO MATCHES "${flag}" )
|
||||||
|
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${flag} ")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Add the debug flags
|
||||||
|
foreach( flag ${ADDITIONAL_C_DEBUG_FLAGS} )
|
||||||
|
if( NOT CMAKE_C_FLAGS_DEBUG MATCHES "${flag}" )
|
||||||
|
set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${flag} ")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Add the release flags
|
||||||
|
foreach( flag ${ADDITIONAL_C_RELEASE_FLAGS} )
|
||||||
|
if( NOT CMAKE_C_FLAGS_RELEASE MATCHES "${flag}" )
|
||||||
|
set( CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${flag} ")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Add the release with debug info flags
|
||||||
|
foreach( flag ${ADDITIONAL_C_RELWITHDEBINFO_FLAGS} )
|
||||||
|
if( NOT CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES "${flag}" )
|
||||||
|
set( CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${flag} ")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
#TODO : Test and remove it?!
|
||||||
|
IF( CMAKE_SYSTEM MATCHES "SunOS*")
|
||||||
|
set (CMAKE_CFLAGS_RELEASE "-xO3")
|
||||||
|
set (CMAKE_CXX_FLAGS_RELEASE "-xO3")
|
||||||
|
endif ( CMAKE_SYSTEM MATCHES "SunOS*" )
|
||||||
|
|
||||||
endif ()
|
endif ()
|
||||||
|
|||||||
Reference in New Issue
Block a user