From: vsr Date: Thu, 19 Jan 2017 12:21:37 +0000 (+0300) Subject: Patch for MacOS (from SALOME forum) X-Git-Tag: SHAPER_2.7.0~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=36031232b16e1089b30d6e1664d10f729f56ba78;p=tools%2Fconfiguration.git Patch for MacOS (from SALOME forum) + Clean-up deprecated code + Minor improvements --- diff --git a/cmake/FindPyQt4.cmake b/cmake/FindPyQt4.cmake index e9f0795..61e9e48 100644 --- a/cmake/FindPyQt4.cmake +++ b/cmake/FindPyQt4.cmake @@ -65,7 +65,7 @@ ENDIF() MARK_AS_ADVANCED(PYQT_SIP_MAIN_FILE) # Get PyQt compilation flags: -SET(PYQT_PYTHONPATH ${_tmp_ROOT_DIR}/PyQt4) +SET(PYQT_PYTHONPATH "${_tmp_ROOT_DIR}/PyQt4;${_tmp_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/PyQt4") SET(PYQT_SIPFLAGS) EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; diff --git a/cmake/FindPyQt5.cmake b/cmake/FindPyQt5.cmake index b72c418..593e4c4 100644 --- a/cmake/FindPyQt5.cmake +++ b/cmake/FindPyQt5.cmake @@ -65,7 +65,7 @@ ENDIF() MARK_AS_ADVANCED(PYQT_SIP_MAIN_FILE) # Get PyQt compilation flags: -SET(PYQT_PYTHONPATH ${_tmp_ROOT_DIR}/PyQt5) +SET(PYQT_PYTHONPATH "${_tmp_ROOT_DIR}/PyQt5;${_tmp_ROOT_DIR}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/PyQt5") SET(PYQT_SIPFLAGS) EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "import sys; diff --git a/cmake/FindSalomePythonLibs.cmake b/cmake/FindSalomePythonLibs.cmake index 3ad5367..c814298 100644 --- a/cmake/FindSalomePythonLibs.cmake +++ b/cmake/FindSalomePythonLibs.cmake @@ -38,6 +38,20 @@ ENDIF() IF(WIN32) set(CMAKE_LIBRARY_PATH "${PYTHON_ROOT_DIR}/libs") ENDIF() +IF(APPLE) + FIND_PROGRAM(PYTHON_CONFIG_EXECUTABLE python-config) + IF(NOT PYTHON_CONFIG_EXECUTABLE) + MESSAGE(SEND_ERROR "python-config executable not found, but python is required.") + ENDIF() + EXECUTE_PROCESS(COMMAND ${PYTHON_CONFIG_EXECUTABLE} --prefix OUTPUT_VARIABLE python_prefix OUTPUT_STRIP_TRAILING_WHITESPACE) + SET(PYTHON_INCLUDE_DIR ${python_prefix}/include/python2.7) + SET(PYTHON_LIBRARY ${python_prefix}/lib/libpython2.7${CMAKE_SHARED_LIBRARY_SUFFIX}) + SET(PYTHON_MAJOR_VERSION 2) + SET(PYTHON_MINOR_VERSION 7) + MESSAGE(STATUS "Python libraries: ${PYTHON_LIBRARY}") + MESSAGE(STATUS "Python include dir: ${PYTHON_INCLUDE_DIR}") +ENDIF() + SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(PythonLibs PYTHON_INCLUDE_DIR 2) IF(SALOMEPYTHONLIBS_FOUND) diff --git a/cmake/SalomeMacros.cmake b/cmake/SalomeMacros.cmake index 3daf597..0b5d61b 100644 --- a/cmake/SalomeMacros.cmake +++ b/cmake/SalomeMacros.cmake @@ -812,9 +812,15 @@ MACRO(SALOME_GENERATE_ENVIRONMENT_SCRIPT output script cmd opts) SET(_item PATH) ENDIF() STRING(REPLACE "/" "\\" _env "${_env} @SET ${_item}=${_val};%${_item}%\n") - ELSE(WIN32) + ELSEIF(APPLE) + IF(${_item} STREQUAL "LD_LIBRARY_PATH") + SET(_env "${_env} export DYLD_LIBRARY_PATH=${_val}:\${DYLD_LIBRARY_PATH}\n") + ELSE() + SET(_env "${_env} export ${_item}=${_val}:\${${_item}}\n") + ENDIF() + ELSE() SET(_env "${_env} export ${_item}=${_val}:\${${_item}}\n") - ENDIF(WIN32) + ENDIF() ENDFOREACH() ENDFOREACH() diff --git a/cmake/SalomeSetupPlatform.cmake b/cmake/SalomeSetupPlatform.cmake index ebff56e..2948168 100644 --- a/cmake/SalomeSetupPlatform.cmake +++ b/cmake/SalomeSetupPlatform.cmake @@ -46,42 +46,16 @@ ELSE() SET(PYLOGLEVEL WARNING) ENDIF() -## Make all warnings errors on non-windows platforms -# CURRENTLY DISABLED +## Treat all warnings as errors IF(NOT (WIN32 OR APPLE)) - SET(ADD_WERROR ON) - SET(NAMES ACCEPT_SALOME_WARNINGS ACCEPT_${MODULE}_WARNINGS I_AM_A_TROLL_I_DO_NOT_FIX_${MODULE}_WARNINGS) - FOREACH(name ${NAMES}) - SET(VAL $ENV{${name}}) - IF("${VAL}" STREQUAL "0") - SET(ADD_WERROR ON) - ENDIF() - IF("${VAL}" STREQUAL "1") - SET(ADD_WERROR OFF) - ENDIF() - ENDFOREACH() - - IF(ADD_WERROR) -# SET(CMAKE_C_FLAGS "-Werror") -# SET(CMAKE_CXX_FLAGS "-Werror") + OPTION(SALOME_DEBUG_WARNINGS "Treat warnings as errors" OFF) + MARK_AS_ADVANCED(SALOME_DEBUG_WARNINGS) + IF(SALOME_DEBUG_WARNINGS) + SET(CMAKE_C_FLAGS "-Werror") + SET(CMAKE_CXX_FLAGS "-Werror") ENDIF() ENDIF() -## TODO: remove this ? -#IF(WIN32) -# MARK_AS_ADVANCED(CLEAR CMAKE_CONFIGURATION_TYPES) -# SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE} CACHE STRING "compilation types" FORCE) -#ELSE() -# IF(CMAKE_BUILD_TYPE STREQUAL Debug) -# SET(CMAKE_C_FLAGS_DEBUG "-g") -# SET(CMAKE_CXX_FLAGS_DEBUG "-g") -# ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug) -# IF(CMAKE_BUILD_TYPE STREQUAL Release) -# SET(CMAKE_C_FLAGS_RELEASE "-O1 -DNDEBUG") -# SET(CMAKE_CXX_FLAGS_RELEASE "-O1 -DNDEBUG") -# ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) -#ENDIF() - IF(WIN32) ## Windows specific: ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) # To disable windows warnings for strcpy, fopen, ... @@ -89,56 +63,18 @@ IF(WIN32) ADD_DEFINITIONS(-DWNT -DWIN32) ADD_DEFINITIONS(-D_WIN32_WINNT=0x0500) # Windows 2000 or later API is required ADD_DEFINITIONS(-DPPRO_NT) # For medfile - #ADD_DEFINITIONS(-D_USE_MATH_DEFINES) # for MEDMEM - + SET(PLATFORM_LIBS Ws2_32.lib) LIST(APPEND PLATFORM_LIBS Userenv.lib) # At least for GEOM suit -################################################################################################ -# -# RNV: In the SALOME sometimes operating with STL collections is done in not fully valid way. -# To avoid run-time exception in Debug mode default values of the _SECURE_SCL, -# _SECURE_SCL_THROWS and _HAS_ITERATOR_DEBUGGING macros were redefined. It solved a problem -# then we used tne Microsoft Visual Studio 2008 to build SALOME on Windows platform. -# But in the Microsoft Visual Studio 2010 these macros affect on the size of STL collection -# classes(in difference from the Microsoft Visual Studio 2008: in this version of MSVS size -# of the STL collection classes does not depend on these macros). -# All pre-requisite products are built by MSVS 2010 in Debug mode with the default -# values of the metioned above macros (namely _SECURE_SCL=1, _HAS_ITERATOR_DEBUGGING=1 and -# _SECURE_SCL_THROWS=1). So SALOME modules should be build in the same configuration. -# -################################################################################################ -# -# # Disable iterator debugging on WINDOWS to avoid runtime error during checking iterators -# # _SECURE_SCL -# # If defined as 1, unsafe iterator use causes a runtime error. -# # If defined as 0, checked iterators are disabled. -# # The default value for _SECURE_SCL is 1 -# # _SECURE_SCL_THROWS -# # If defined as 1, an out of range iterator use causes an exception at runtime. -# # If defined as 0, the program is terminated by calling invalid_parameter. -# # The default value for _SECURE_SCL_THROWS is 0 -# -# ADD_DEFINITIONS(-D_SECURE_SCL=0 -D_SECURE_SCL_THROWS=0) -# -# # The symbol _HAS_ITERATOR_DEBUGGING can be used to turn off the iterator debugging feature in a debug build -# # If defined as 1, iterator debugging is enabled. -# # If defined as 0, iterator debugging is disabled. -# # The default value for _HAS_ITERATOR_DEBUGGING is 1 -# -# IF(NOT CMAKE_BUILD_TYPE STREQUAL "RELEASE" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release") -# ADD_DEFINITIONS(-D_HAS_ITERATOR_DEBUGGING=0) -# ENDIF(NOT CMAKE_BUILD_TYPE STREQUAL "RELEASE" AND NOT CMAKE_BUILD_TYPE STREQUAL "Release") -################################################################################################ - IF(MACHINE_IS_64) - SET(SIZE_OF_LONG 4) # set sizeof(long) to 4 byte + SET(SIZE_OF_LONG 4) # Set sizeof(long) to 4 bytes ELSE() - SET(SIZE_OF_LONG ${CMAKE_SIZEOF_VOID_P}) # set sizeof(long) the same as size of pointers + SET(SIZE_OF_LONG ${CMAKE_SIZEOF_VOID_P}) # Set sizeof(long) the same as size of pointers ENDIF() ELSE() ## Linux specific: - SET(PLATFORM_LIBS dl) # Dynamic loading (dlopen, dlsym) + SET(PLATFORM_LIBS dl) # Dynamic loading (dlopen, dlsym) IF(MACHINE_IS_64) ADD_DEFINITIONS(-DPCLINUX64) ENDIF(MACHINE_IS_64) @@ -151,9 +87,13 @@ ENDIF() ## Apple specific: IF(APPLE) - SET(CMAKE_C_COMPILER gcc) - SET(CMAKE_CXX_COMPILER g++) - # because default is clang(llvm) with mountain lion at least + # Default is clang(llvm) with mountain lion at least + OPTION(SALOME_APPLE_USE_GCC "Use GCC compiler" OFF) + MARK_AS_ADVANCED(SALOME_APPLE_USE_GCC) + IF(SALOME_APPLE_USE_GCC) + SET(CMAKE_C_COMPILER gcc) + SET(CMAKE_CXX_COMPILER g++) + ENDIF() ENDIF() # Compiler flags for coverage testing diff --git a/cmake/UseOmniORB.cmake b/cmake/UseOmniORB.cmake index 72143d6..4995535 100644 --- a/cmake/UseOmniORB.cmake +++ b/cmake/UseOmniORB.cmake @@ -19,9 +19,9 @@ INSTALL( CODE " SET(INSTALL_PYIDL_DIR lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/salome) # R1 CHECK -IF(WIN32) +IF(WIN32 OR APPLE) SET(INSTALL_PYIDL_DIR bin/salome) # R1 CHECK -ENDIF(WIN32) +ENDIF(WIN32 OR APPLE) MACRO(OMNIORB_COMPILE_IDL_FORPYTHON_ON_INSTALL MYOMNIORBIDLPYTHON MYIDLPYFLAGS MYIDLFILE MYFULLDIR) FILE(MAKE_DIRECTORY \${MYFULLDIR})