Cleanup CMake build system

- Use CMAKE_INSTALL_PREFIX instead of INSTALL_DIR
  - Allow finer control of install directories
  - Use compiled TCL code by default
  - Fix RPATH usage on Linux and MacOSX

### Allow finer control of install directories
The following variables can be set to either absolute or relative paths
NG_INSTALL_DIR_PYTHON: Python files
NG_INSTALL_DIR_BIN: Executables
NG_INSTALL_DIR_LIB: Libraries
NG_INSTALL_DIR_INCLUDE: header files
NG_INSTALL_DIR_CMAKE: CMake files
NG_INSTALL_DIR_RES: Resources

### Use compiled TCL code by default
The tcl files contained in Netgen are stored in onetcl.cpp as c-string.
This way it's not necessary to install tcl files or set NETGENDIR

### Fix RPATH usage on Linux and MacOSX
The Netgen installation should be completely relocatable now.

Squashed commit of the following:

commit 201eda5e62726bd87d76beb13c3e5643cd4c7810
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 21:10:08 2017 +0200

    cleanup

commit b4cd46a9d2f390b40c5223c8d9971f576b979644
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 20:47:46 2017 +0200

    fix

commit 6506a834dbee2fd7b6df3b3f3709d0b27344356f
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 20:41:45 2017 +0200

    allow gui test to fail

commit 56c5fc131f61259e6fb67b60f7fff955d2e8d2da
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 20:26:18 2017 +0200

    add python3-tk to docker images

commit 4d1b5aac1d028867339819599708a08f2098bbd6
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 11:22:18 2017 -0700

    windows fix

commit 92b5f8a95491ba3508143d7f1b94359edc0655ce
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 11:08:08 2017 -0700

    fix for windows

commit 3f7bf51434ef3b637b3563930ddb61d04af645cb
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 19:28:13 2017 +0200

    fixes, test for gui

commit ef1d0164a50fadf374e3b1e43a745b5f69a16ad6
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 19:06:55 2017 +0200

    fixes

commit 67645bb896012149c23c851b03287199c21fa129
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 17:24:58 2017 +0200

    netgen config

commit b587b77a282768719cffc366c56d82a1746e0be0
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 16:53:47 2017 +0200

    remove comments

commit 2b34cc78818afa1cf21484bd0976413a91db0851
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 05:03:00 2017 -0700

    fix windows

commit 9e98efa54065624e264eaf1acf74b44ef022a68d
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 13:42:11 2017 +0200

    fixes

commit 394b470a07d73431079f80caa36c7c7042077f40
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 12:24:40 2017 +0200

    fix rpath issue

commit 6787eae384a8592f90598258ccd8207cd499d9fc
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 11:37:05 2017 +0200

    some more fixes with install dir

commit fcf22659c60300e8d39d12e14b21c58a062e739c
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 01:34:06 2017 -0700

    some fixes

commit ede1f0c462978bb70d3b4e2251cb555a592e82e3
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 29 10:16:34 2017 +0200

    fixes

commit b6a1259876a77f54e419a44f1b44d03d5bb49b82
Merge: c79f9a3 6627b0b
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Wed May 24 09:35:50 2017 +0200

    Merge remote-tracking branch 'origin/master' into cmake_cleanup

commit c79f9a3421d4d2937c31dab4a601ce09d52b0e54
Merge: 99c3550 030ad1d
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Mon May 22 17:52:24 2017 +0200

    Merge remote-tracking branch 'origin/master' into cmake_cleanup

commit 99c35500850e08fdc847013bb384169b1483acb4
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Fri May 19 14:37:28 2017 +0200

    fix rpath

commit 8215e9748d9ee225266bc941da1ca252aebd27de
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Thu May 18 13:29:41 2017 +0200

    remove INSTALL_DIR, rename var to NETGEN_INSTALL_DIR_INCLUDE, install libngpy to python package folder

commit 23d028c4cf7572de9e2e277cda8f6b07b6b1d9f9
Merge: 57027c8 f72a247
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Thu May 18 12:03:59 2017 +0200

    Merge remote-tracking branch 'origin/master' into cmake_cleanup

commit 57027c8c706ff755bdf26887884bbdeca129fe8f
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Fri May 12 17:32:05 2017 +0200

    New CMake option: USE_INTERNAL_TCL (ON by default)

    This option uses the tcl code compiled in onetcl.cpp instead of separate
    tcl files by default. When set at configure time, no tcl files will be
    installed anymore.

commit 27ce5b7edd66d64e2453f5045f5ac08c313f7608
Author: Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
Date:   Fri May 12 17:16:52 2017 +0200

    WIP: Cleanup of CMake files

      - Fix RPATH on Linux (TODO: other platforms)
      - New variables to specify install behaviour:
          NG_INSTALL_DIR_BIN
          NG_INSTALL_DIR_LIB
          NG_INSTALL_DIR_CMAKE
          NG_INSTALL_DIR_INCLUDE
This commit is contained in:
Matthias Hochsteger 2017-05-29 21:19:34 +02:00
parent 6627b0b17f
commit f6a0b31b96
36 changed files with 249 additions and 160 deletions

View File

@ -16,19 +16,51 @@ option( USE_MPEG "enable video recording with FFmpeg, uses libavcodec" OFF )
option( INTEL_MIC "cross compile for intel xeon phi") option( INTEL_MIC "cross compile for intel xeon phi")
option( INSTALL_PROFILES "install environment variable settings to /etc/profile.d" OFF ) option( INSTALL_PROFILES "install environment variable settings to /etc/profile.d" OFF )
option( USE_CCACHE "use ccache") option( USE_CCACHE "use ccache")
option( USE_INTERNAL_TCL "Compile tcl files into the code and don't install them" ON)
option( USE_SUPERBUILD "use ccache" ON) option( USE_SUPERBUILD "use ccache" ON)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_modules") set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_modules")
if(APPLE)
set(INSTALL_DIR_DEFAULT /Applications/Netgen.app)
else(APPLE)
if(WIN32)
set(INSTALL_DIR_DEFAULT "C:/netgen")
else(WIN32)
set(INSTALL_DIR_DEFAULT /opt/netgen)
endif(WIN32)
endif(APPLE)
if(INSTALL_DIR)
message(WARNING "INSTALL_DIR is deprecated, use CMAKE_INSTALL_PREFIX instead")
set(INSTALL_DIR_DEFAULT ${INSTALL_DIR})
endif(INSTALL_DIR)
if(UNIX)
message("Checking for write permissions in install directory...")
execute_process(COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX})
execute_process(COMMAND test -w ${CMAKE_INSTALL_PREFIX} RESULT_VARIABLE res)
if(res)
message(WARNING "No write access at install directory, please set correct permissions")
endif()
endif(UNIX)
if (USE_SUPERBUILD) if (USE_SUPERBUILD)
project (SUPERBUILD) project (SUPERBUILD)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR_DEFAULT}" CACHE PATH "Install directory" FORCE)
endif()
# execute the superbuild (this script will be invoked again without the # execute the superbuild (this script will be invoked again without the
# USE_SUPERBUILD option this time) # USE_SUPERBUILD option this time)
include (cmake/SuperBuild.cmake) include (cmake/SuperBuild.cmake)
return() # stop processing this file further return() # stop processing this file further
else() else()
project(Netgen) project(Netgen)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR_DEFAULT}" CACHE PATH "Install directory" FORCE)
endif()
endif() endif()
set(NETGEN_VERSION_MAJOR 6) set(NETGEN_VERSION_MAJOR 6)
@ -68,43 +100,68 @@ if (ADDITIONAL_PATHS)
set(CMAKE_PREFIX_PATH ${ADDITIONAL_PATHS}) set(CMAKE_PREFIX_PATH ${ADDITIONAL_PATHS})
endif (ADDITIONAL_PATHS) endif (ADDITIONAL_PATHS)
if(APPLE)
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}/Contents/Resources" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
else(APPLE)
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
endif(APPLE)
#######################################################################
# use rpath
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
####################################################################### #######################################################################
# build options # build options
add_definitions(-DUSE_TIMEOFDAY)
include_directories ("${PROJECT_SOURCE_DIR}/include") include_directories ("${PROJECT_SOURCE_DIR}/include")
include_directories ("${PROJECT_SOURCE_DIR}/libsrc/include") include_directories ("${PROJECT_SOURCE_DIR}/libsrc/include")
include_directories ("${PROJECT_BINARY_DIR}") include_directories ("${PROJECT_BINARY_DIR}")
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(INCDIR include CACHE PATH "install directory for header files")
if(APPLE) if(APPLE)
set(ng_install_dir_bin ../MacOS) set(NG_INSTALL_DIR_BIN_DEFAULT Contents/MacOS)
set(ng_install_dir_lib ../MacOS) set(NG_INSTALL_DIR_LIB_DEFAULT Contents/MacOS)
set(NG_INSTALL_DIR_CMAKE_DEFAULT Contents/Resources/share/cmake)
set(NG_INSTALL_DIR_PYTHON_DEFAULT Contents/Resources/${PYTHON_PACKAGES_INSTALL_DIR})
set(NG_INSTALL_DIR_RES_DEFAULT Contents/Resources/share)
set(NG_INSTALL_DIR_INCLUDE_DEFAULT Contents/Resources/include)
set(NG_RPATH_TOKEN "@loader_path")
else(APPLE) else(APPLE)
set(ng_install_dir_bin bin) set(NG_INSTALL_DIR_BIN_DEFAULT bin)
set(ng_install_dir_lib lib) set(NG_INSTALL_DIR_LIB_DEFAULT lib)
set(NG_INSTALL_DIR_CMAKE_DEFAULT lib/cmake)
set(NG_INSTALL_DIR_PYTHON_DEFAULT ${PYTHON_PACKAGES_INSTALL_DIR})
set(NG_INSTALL_DIR_RES_DEFAULT share)
set(NG_INSTALL_DIR_INCLUDE_DEFAULT include)
set(NG_RPATH_TOKEN "\$ORIGIN")
endif(APPLE) endif(APPLE)
set(ng_install_dir EXPORT netgen-targets RUNTIME DESTINATION ${ng_install_dir_bin} COMPONENT netgen LIBRARY DESTINATION ${ng_install_dir_lib} COMPONENT netgen_devel ARCHIVE DESTINATION ${ng_install_dir_lib} COMPONENT netgen_devel)
install(EXPORT netgen-targets DESTINATION share/cmake) set(NG_INSTALL_SUFFIX netgen CACHE STRING "Suffix appended to install directories (project name)")
set(NG_INSTALL_DIR_PYTHON ${NG_INSTALL_DIR_PYTHON_DEFAULT} CACHE STRING "Install directory for Python files")
set(NG_INSTALL_DIR_BIN ${NG_INSTALL_DIR_BIN_DEFAULT} CACHE STRING "Install directory for executables")
set(NG_INSTALL_DIR_LIB ${NG_INSTALL_DIR_LIB_DEFAULT} CACHE STRING "Install directory for libraries")
set(NG_INSTALL_DIR_INCLUDE ${NG_INSTALL_DIR_INCLUDE_DEFAULT} CACHE STRING "Install directory for header files")
set(NG_INSTALL_DIR_CMAKE ${NG_INSTALL_DIR_CMAKE_DEFAULT} CACHE STRING "Install directory for CMake files")
set(NG_INSTALL_DIR_RES ${NG_INSTALL_DIR_RES_DEFAULT} CACHE STRING "Install directory for resources")
get_filename_component(NETGEN_CMAKE_DIR_ABSOLUTE ${NG_INSTALL_DIR_CMAKE} ABSOLUTE BASE_DIR ${CMAKE_INSTALL_PREFIX})
get_filename_component(NETGEN_BINARY_DIR_ABSOLUTE ${NG_INSTALL_DIR_BIN} ABSOLUTE BASE_DIR ${CMAKE_INSTALL_PREFIX})
get_filename_component(NETGEN_LIBRARY_DIR_ABSOLUTE ${NG_INSTALL_DIR_LIB} ABSOLUTE BASE_DIR ${CMAKE_INSTALL_PREFIX})
get_filename_component(NETGEN_INCLUDE_DIR_ABSOLUTE ${NG_INSTALL_DIR_INCLUDE} ABSOLUTE BASE_DIR ${CMAKE_INSTALL_PREFIX})
get_filename_component(NETGEN_PYTHON_DIR_ABSOLUTE ${NG_INSTALL_DIR_PYTHON} ABSOLUTE BASE_DIR ${CMAKE_INSTALL_PREFIX})
get_filename_component(NETGEN_RESOURCE_DIR_ABSOLUTE ${NG_INSTALL_DIR_RES} ABSOLUTE BASE_DIR ${CMAKE_INSTALL_PREFIX})
file(RELATIVE_PATH NETGEN_DIR ${NETGEN_CMAKE_DIR_ABSOLUTE} ${CMAKE_INSTALL_PREFIX})
file(RELATIVE_PATH NETGEN_BINARY_DIR ${NETGEN_CMAKE_DIR_ABSOLUTE} ${NETGEN_BINARY_DIR_ABSOLUTE})
file(RELATIVE_PATH NETGEN_LIBRARY_DIR ${NETGEN_CMAKE_DIR_ABSOLUTE} ${NETGEN_LIBRARY_DIR_ABSOLUTE})
file(RELATIVE_PATH NETGEN_INCLUDE_DIR ${NETGEN_CMAKE_DIR_ABSOLUTE} ${NETGEN_INCLUDE_DIR_ABSOLUTE})
file(RELATIVE_PATH NETGEN_PYTHON_DIR ${NETGEN_CMAKE_DIR_ABSOLUTE} ${NETGEN_PYTHON_DIR_ABSOLUTE})
file(RELATIVE_PATH NETGEN_RESOURCE_DIR ${NETGEN_CMAKE_DIR_ABSOLUTE} ${NETGEN_RESOURCE_DIR_ABSOLUTE})
file(RELATIVE_PATH NETGEN_RPATH ${NETGEN_BINARY_DIR_ABSOLUTE} ${NETGEN_LIBRARY_DIR_ABSOLUTE})
file(RELATIVE_PATH NETGEN_PYTHON_RPATH_BIN ${NETGEN_PYTHON_DIR_ABSOLUTE} ${NETGEN_BINARY_DIR_ABSOLUTE})
file(RELATIVE_PATH NETGEN_PYTHON_RPATH ${NETGEN_PYTHON_DIR_ABSOLUTE} ${NETGEN_LIBRARY_DIR_ABSOLUTE})
if(WIN32)
set(NETGEN_PYTHON_RPATH ${NETGEN_PYTHON_RPATH_BIN})
endif(WIN32)
set(NG_INSTALL_DIR EXPORT netgen-targets RUNTIME DESTINATION ${NG_INSTALL_DIR_BIN} COMPONENT netgen LIBRARY DESTINATION ${NG_INSTALL_DIR_LIB} COMPONENT netgen_devel ARCHIVE DESTINATION ${NG_INSTALL_DIR_LIB} COMPONENT netgen_devel)
install(EXPORT netgen-targets DESTINATION ${NG_INSTALL_DIR_CMAKE} )
set(CMAKE_MACOSX_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "${NG_RPATH_TOKEN};${NG_RPATH_TOKEN}/${NETGEN_RPATH}")
include (CheckIncludeFiles) include (CheckIncludeFiles)
check_include_files (dlfcn.h HAVE_DLFCN_H) check_include_files (dlfcn.h HAVE_DLFCN_H)
@ -185,8 +242,8 @@ if (USE_PYTHON)
include_directories(${PYBIND_INCLUDE_DIR}) include_directories(${PYBIND_INCLUDE_DIR})
include_directories(${PYTHON_INCLUDE_DIRS}) include_directories(${PYTHON_INCLUDE_DIRS})
install(DIRECTORY ${PYBIND_INCLUDE_DIR}/pybind11 DESTINATION ${INCDIR} COMPONENT netgen_devel) install(DIRECTORY ${PYBIND_INCLUDE_DIR}/pybind11 DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel)
install(FILES ${PYBIND_INCLUDE_DIR}/../LICENSE DESTINATION ${INCDIR}/pybind11 COMPONENT netgen_devel) install(FILES ${PYBIND_INCLUDE_DIR}/../LICENSE DESTINATION ${NG_INSTALL_DIR_INCLUDE}/pybind11 COMPONENT netgen_devel)
endif (USE_PYTHON) endif (USE_PYTHON)
####################################################################### #######################################################################
@ -222,10 +279,10 @@ endif (USE_MPEG)
####################################################################### #######################################################################
if(INSTALL_PROFILES) if(INSTALL_PROFILES)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "#!/bin/sh\n") file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "#!/bin/sh\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export PATH=${INSTALL_DIR}/bin:$PATH\n") file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export PATH=${CMAKE_INSTALL_PREFIX}/bin:$PATH\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export NETGENDIR=${INSTALL_DIR}/bin\n") file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export NETGENDIR=${CMAKE_INSTALL_PREFIX}/bin\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export PYTHONPATH=${INSTALL_DIR}/${PYTHON_PACKAGES_INSTALL_DIR}:.\n") file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${PYTHON_PACKAGES_INSTALL_DIR}:.\n")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export LD_LIBRARY_PATH=${INSTALL_DIR}/lib:.\n") file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:.\n")
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh DESTINATION /etc/profile.d COMPONENT netgen) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh DESTINATION /etc/profile.d COMPONENT netgen)
string(ASCII 27 Esc) string(ASCII 27 Esc)
@ -237,19 +294,19 @@ endif(INSTALL_PROFILES)
####################################################################### #######################################################################
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/fixup.cmake "\ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/fixup.cmake "\
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/netgen_fixup.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/netgen_fixup.cmake)
set(APP ${INSTALL_DIR}) set(APP ${CMAKE_INSTALL_PREFIX})
message(\${APP}) message(\${APP})
set(BU_CHMOD_BUNDLE_ITEMS ON) set(BU_CHMOD_BUNDLE_ITEMS ON)
file(GLOB libs ${CMAKE_INSTALL_PREFIX}/${ng_install_dir_lib}/*.dylib ${CMAKE_INSTALL_PREFIX}/${ng_install_dir_lib}/*.so) file(GLOB libs ${CMAKE_INSTALL_PREFIX}/${NG_INSTALL_DIR_LIB}/*.dylib ${CMAKE_INSTALL_PREFIX}/${NG_INSTALL_DIR_LIB}/*.so)
message(\"\${libs}\") message(\"\${libs}\")
netgen_fixup_bundle( \${APP}/Contents/MacOS/netgen \"\${libs}\" ${CMAKE_INSTALL_PREFIX}/${ng_install_dir_lib} ) netgen_fixup_bundle( \${APP}/Contents/MacOS/netgen \"\${libs}\" ${CMAKE_INSTALL_PREFIX}/${NG_INSTALL_DIR_LIB} )
execute_process(COMMAND ln -s /Applications ${INSTALL_DIR}/../Applications) execute_process(COMMAND ln -s /Applications ${CMAKE_INSTALL_PREFIX}/../Applications)
set (bundle_filename \$ENV{NETGEN_BUNDLE_NAME}) set (bundle_filename \$ENV{NETGEN_BUNDLE_NAME})
if(NOT bundle_filename) if(NOT bundle_filename)
set(bundle_filename netgen) set(bundle_filename netgen)
endif(NOT bundle_filename) endif(NOT bundle_filename)
execute_process(COMMAND hdiutil create -volname Netgen -srcfolder ${INSTALL_DIR} -ov -format UDZO \${bundle_filename}-${PACKAGE_VERSION}.dmg) execute_process(COMMAND hdiutil create -volname Netgen -srcfolder ${CMAKE_INSTALL_PREFIX} -ov -format UDZO \${bundle_filename}-${PACKAGE_VERSION}.dmg)
") ")
add_custom_target(bundle COMMAND ${CMAKE_COMMAND} "-P" "${CMAKE_CURRENT_BINARY_DIR}/fixup.cmake") add_custom_target(bundle COMMAND ${CMAKE_COMMAND} "-P" "${CMAKE_CURRENT_BINARY_DIR}/fixup.cmake")
####################################################################### #######################################################################
@ -323,7 +380,7 @@ export PYTHONPATH=$Netgen_BUNDLE/Contents/Resources/${PYTHON_PACKAGES_INSTALL_DI
cd $Netgen_MACOS cd $Netgen_MACOS
$Netgen_MACOS/netgen $Netgen_MACOS/netgen
") ")
install(PROGRAMS ${mac_startup} DESTINATION ${ng_install_dir_bin}) install(PROGRAMS ${mac_startup} DESTINATION ${NG_INSTALL_DIR_BIN})
set(mac_ngsuite ${CMAKE_CURRENT_BINARY_DIR}/ngsuite.sh) set(mac_ngsuite ${CMAKE_CURRENT_BINARY_DIR}/ngsuite.sh)
file(WRITE ${mac_ngsuite} "\ file(WRITE ${mac_ngsuite} "\
@ -332,7 +389,7 @@ Netgen_BUNDLE=\"`echo \"$0\" | sed -e 's/\\/Contents\\/MacOS\\/Netgen1//'`\"
Netgen_MACOS=\"$Netgen_BUNDLE/Contents/MacOS\" Netgen_MACOS=\"$Netgen_BUNDLE/Contents/MacOS\"
open -a /Applications/Utilities/Terminal.app $Netgen_MACOS/startup.sh open -a /Applications/Utilities/Terminal.app $Netgen_MACOS/startup.sh
") ")
install(PROGRAMS ${mac_ngsuite} DESTINATION ../MacOS RENAME Netgen1) install(PROGRAMS ${mac_ngsuite} DESTINATION ${NG_INSTALL_DIR_BIN} RENAME Netgen1)
set(mac_plist ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) set(mac_plist ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
file(WRITE ${mac_plist} "<?xml version=\"1.0\" encoding=\"UTF-8\"?> file(WRITE ${mac_plist} "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
@ -350,8 +407,8 @@ open -a /Applications/Utilities/Terminal.app $Netgen_MACOS/startup.sh
</dict> </dict>
</plist> </plist>
") ")
install(FILES ${mac_plist} DESTINATION ../) install(FILES ${mac_plist} DESTINATION ${NG_INSTALL_DIR_BIN}/../)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/netgen.icns DESTINATION . RENAME Netgen.icns) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/netgen.icns DESTINATION ${NG_INSTALL_DIR_RES}/../ RENAME Netgen.icns)
endif(APPLE) endif(APPLE)
@ -368,10 +425,14 @@ configure_file(
add_custom_target(uninstall add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
#######################################################################
# Generate package config file
get_directory_property(NETGEN_COMPILE_DEFINITIONS COMPILE_DEFINITIONS)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/NetgenConfig.cmake.in configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/NetgenConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/NetgenConfig.cmake @ONLY) ${CMAKE_CURRENT_BINARY_DIR}/NetgenConfig.cmake @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/NetgenConfig.cmake DESTINATION share/cmake) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/NetgenConfig.cmake DESTINATION ${NG_INSTALL_DIR_CMAKE})
####################################################################### #######################################################################
# Configure message # Configure message

View File

@ -1,7 +1,17 @@
set(PACKAGE_VERSION "@NETGEN_VERSION@") set(PACKAGE_VERSION "@NETGEN_VERSION@")
set(NETGEN_DIR "@CMAKE_INSTALL_PREFIX@")
set(NETGEN_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/@INCDIR@") get_filename_component(NETGEN_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(NETGEN_DIR "${NETGEN_CMAKE_DIR}/@NETGEN_DIR@")
set(NETGEN_COMPILE_DEFINITIONS "@NETGEN_COMPILE_DEFINITIONS@")
set(NETGEN_INCLUDE_DIR "${NETGEN_CMAKE_DIR}/@NETGEN_INCLUDE_DIR@/include;${NETGEN_CMAKE_DIR}/@NETGEN_INCLUDE_DIR@")
set(NETGEN_BINARY_DIR "${NETGEN_CMAKE_DIR}/@NETGEN_BINARY_DIR@")
set(NETGEN_LIBRARY_DIR "${NETGEN_CMAKE_DIR}/@NETGEN_LIBRARY_DIR@")
set(NETGEN_PYTHON_DIR "${NETGEN_CMAKE_DIR}/@NETGEN_PYTHON_DIR@")
set(NETGEN_RESOURCE_DIR "${NETGEN_CMAKE_DIR}/@NETGEN_RESOURCE_DIR@")
set(NETGEN_SOURCE_DIR "@PROJECT_SOURCE_DIR@") set(NETGEN_SOURCE_DIR "@PROJECT_SOURCE_DIR@")
set(NETGEN_CMAKE_THREAD_LIBS_INIT "@CMAKE_THREAD_LIBS_INIT@") set(NETGEN_CMAKE_THREAD_LIBS_INIT "@CMAKE_THREAD_LIBS_INIT@")
@ -14,7 +24,6 @@ set(NETGEN_METIS_LIBRARY "@METIS_LIBRARY@")
set(NETGEN_MKL_LIBRARIES "@MKL_LIBRARIES@") set(NETGEN_MKL_LIBRARIES "@MKL_LIBRARIES@")
set(NETGEN_MPI_CXX_INCLUDE_PATH "@MPI_CXX_INCLUDE_PATH@") set(NETGEN_MPI_CXX_INCLUDE_PATH "@MPI_CXX_INCLUDE_PATH@")
set(NETGEN_MPI_CXX_LIBRARIES "@MPI_CXX_LIBRARIES@") set(NETGEN_MPI_CXX_LIBRARIES "@MPI_CXX_LIBRARIES@")
set(NETGEN_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/@INCDIR@;@CMAKE_INSTALL_PREFIX@/@INCDIR@/include")
set(NETGEN_OCC_INCLUDE_DIR "@OCC_INCLUDE_DIR@") set(NETGEN_OCC_INCLUDE_DIR "@OCC_INCLUDE_DIR@")
set(NETGEN_OCC_LIBRARIES_BIN "@OCC_LIBRARIES_BIN@") set(NETGEN_OCC_LIBRARIES_BIN "@OCC_LIBRARIES_BIN@")
set(NETGEN_OCC_LIBRARIES "@OCC_LIBRARIES@") set(NETGEN_OCC_LIBRARIES "@OCC_LIBRARIES@")
@ -46,4 +55,4 @@ set(NETGEN_INSTALL_PROFILES @INSTALL_PROFILES@)
set(NETGEN_USE_CCACHE @USE_CCACHE@) set(NETGEN_USE_CCACHE @USE_CCACHE@)
include(${CMAKE_CURRENT_LIST_DIR}/netgen-targets.cmake) include(${CMAKE_CURRENT_LIST_DIR}/netgen-targets.cmake)
message(STATUS "Found Netgen: ${NETGEN_DIR}") message(STATUS "Found Netgen: ${CMAKE_CURRENT_LIST_DIR}")

View File

@ -40,19 +40,10 @@ if(WIN32)
endif(${CMAKE_SIZEOF_VOID_P} MATCHES 4) endif(${CMAKE_SIZEOF_VOID_P} MATCHES 4)
endif(WIN32) endif(WIN32)
#######################################################################
# find netgen
if(APPLE)
set(INSTALL_DIR /Applications/Netgen.app CACHE PATH "Install path")
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}/Contents/Resources" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
else(APPLE)
set(INSTALL_DIR /opt/netgen CACHE PATH "Install path")
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
endif(APPLE)
if(UNIX) if(UNIX)
message("Checking for write permissions in install directory...") message("Checking for write permissions in install directory...")
execute_process(COMMAND mkdir -p ${INSTALL_DIR}) execute_process(COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX})
execute_process(COMMAND test -w ${INSTALL_DIR} RESULT_VARIABLE res) execute_process(COMMAND test -w ${CMAKE_INSTALL_PREFIX} RESULT_VARIABLE res)
if(res) if(res)
message(WARNING "No write access at install directory, please set correct permissions") message(WARNING "No write access at install directory, please set correct permissions")
endif() endif()
@ -94,7 +85,7 @@ if(USE_OCC AND WIN32 AND NOT OCC_INCLUDE_DIR)
BUILD_IN_SOURCE 1 BUILD_IN_SOURCE 1
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${INSTALL_DIR} INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${CMAKE_INSTALL_PREFIX}
LOG_DOWNLOAD 1 LOG_DOWNLOAD 1
) )
list(APPEND NETGEN_DEPENDENCIES win_download_occ) list(APPEND NETGEN_DEPENDENCIES win_download_occ)
@ -140,10 +131,11 @@ set_vars( NETGEN_CMAKE_ARGS
USE_NATIVE_ARCH USE_NATIVE_ARCH
USE_OCC USE_OCC
USE_MPEG USE_MPEG
INSTALL_DIR USE_INTERNAL_TCL
INSTALL_PROFILES INSTALL_PROFILES
INTEL_MIC INTEL_MIC
CMAKE_PREFIX_PATH CMAKE_PREFIX_PATH
CMAKE_INSTALL_PREFIX
) )
# propagate all variables set on the command line using cmake -DFOO=BAR # propagate all variables set on the command line using cmake -DFOO=BAR
@ -166,7 +158,7 @@ endif()
ExternalProject_Add (netgen ExternalProject_Add (netgen
DEPENDS ${NETGEN_DEPENDENCIES} DEPENDS ${NETGEN_DEPENDENCIES}
SOURCE_DIR ${PROJECT_SOURCE_DIR} SOURCE_DIR ${PROJECT_SOURCE_DIR}
CMAKE_ARGS -DUSE_SUPERBUILD=OFF ${NETGEN_CMAKE_ARGS} -DCMAKE_PREFIX_PATH=${INSTALL_DIR} CMAKE_ARGS -DUSE_SUPERBUILD=OFF ${NETGEN_CMAKE_ARGS}
INSTALL_COMMAND "" INSTALL_COMMAND ""
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/netgen BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/netgen
BUILD_COMMAND ${NETGEN_BUILD_COMMAND} BUILD_COMMAND ${NETGEN_BUILD_COMMAND}
@ -176,21 +168,21 @@ ExternalProject_Add (netgen
# Check if the git submodules (i.e. pybind11) are up to date # Check if the git submodules (i.e. pybind11) are up to date
# in case, something is wrong, emit a warning but continue # in case, something is wrong, emit a warning but continue
ExternalProject_Add_Step(netgen check_submodules ExternalProject_Add_Step(netgen check_submodules
COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_submodules.cmake COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_submodules.cmake
DEPENDERS install # Steps on which this step depends DEPENDERS install # Steps on which this step depends
) )
# Due to 'ALWAYS 1', this step is always run which also forces a build of # Due to 'ALWAYS 1', this step is always run which also forces a build of
# the Netgen subproject # the Netgen subproject
ExternalProject_Add_Step(netgen check_submodules1 ExternalProject_Add_Step(netgen check_submodules1
COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_submodules.cmake COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_submodules.cmake
DEPENDEES configure # Steps on which this step depends DEPENDEES configure # Steps on which this step depends
DEPENDERS build # Steps that depend on this step DEPENDERS build # Steps that depend on this step
ALWAYS 1 # No stamp file, step always runs ALWAYS 1 # No stamp file, step always runs
) )
install(CODE "execute_process(COMMAND cmake --build . --target install --config ${CMAKE_BUILD_TYPE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/netgen)") install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/netgen)")
add_custom_target(test_netgen add_custom_target(test_netgen
${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/netgen ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/netgen

View File

@ -61,7 +61,7 @@ elseif(WIN32)
BUILD_IN_SOURCE 1 BUILD_IN_SOURCE 1
CONFIGURE_COMMAND "" CONFIGURE_COMMAND ""
BUILD_COMMAND "" BUILD_COMMAND ""
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${INSTALL_DIR} INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${CMAKE_INSTALL_PREFIX}
LOG_DOWNLOAD 1 LOG_DOWNLOAD 1
) )

View File

@ -1 +1 @@
INSTALL(FILES ng4.pdf DESTINATION doc COMPONENT netgen_doc) INSTALL(FILES ng4.pdf DESTINATION ${NG_INSTALL_DIR_RES}/${NG_INSTALL_SUFFIX}/doc COMPONENT netgen_doc)

View File

@ -14,7 +14,7 @@ endif(APPLE)
if(NOT WIN32) if(NOT WIN32)
target_link_libraries(csg mesh ${PYTHON_LIBRARIES}) target_link_libraries(csg mesh ${PYTHON_LIBRARIES})
target_link_libraries(csg ${PYTHON_LIBRARIES}) target_link_libraries(csg ${PYTHON_LIBRARIES})
install( TARGETS csg ${ng_install_dir}) install( TARGETS csg ${NG_INSTALL_DIR})
endif(NOT WIN32) endif(NOT WIN32)
@ -25,7 +25,7 @@ if(USE_GUI)
if(APPLE) if(APPLE)
set_target_properties( csgvis PROPERTIES SUFFIX ".so") set_target_properties( csgvis PROPERTIES SUFFIX ".so")
endif(APPLE) endif(APPLE)
install( TARGETS csgvis ${ng_install_dir}) install( TARGETS csgvis ${NG_INSTALL_DIR})
endif(NOT WIN32) endif(NOT WIN32)
endif(USE_GUI) endif(USE_GUI)
@ -36,5 +36,5 @@ install(FILES
polyhedra.hpp revolution.hpp singularref.hpp solid.hpp polyhedra.hpp revolution.hpp singularref.hpp solid.hpp
specpoin.hpp spline3d.hpp splinesurface.hpp surface.hpp specpoin.hpp spline3d.hpp splinesurface.hpp surface.hpp
triapprox.hpp vscsg.hpp triapprox.hpp vscsg.hpp
DESTINATION ${INCDIR}/csg COMPONENT netgen_devel DESTINATION ${NG_INSTALL_DIR_INCLUDE}/csg COMPONENT netgen_devel
) )

View File

@ -8,7 +8,7 @@ add_library(gen OBJECT
set_target_properties( gen PROPERTIES POSITION_INDEPENDENT_CODE ON ) set_target_properties( gen PROPERTIES POSITION_INDEPENDENT_CODE ON )
install( FILES ngexception.hpp DESTINATION ${INCDIR} COMPONENT netgen_devel ) install( FILES ngexception.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel )
install(FILES install(FILES
archive_base.hpp array.hpp autodiff.hpp autoptr.hpp bitarray.hpp archive_base.hpp array.hpp autodiff.hpp autoptr.hpp bitarray.hpp
@ -17,5 +17,5 @@ install(FILES
optmem.hpp parthreads.hpp profiler.hpp seti.hpp sort.hpp optmem.hpp parthreads.hpp profiler.hpp seti.hpp sort.hpp
spbita2d.hpp stack.hpp symbolta.hpp table.hpp template.hpp spbita2d.hpp stack.hpp symbolta.hpp table.hpp template.hpp
gzstream.h gzstream.h
DESTINATION ${INCDIR}/general COMPONENT netgen_devel DESTINATION ${NG_INSTALL_DIR_INCLUDE}/general COMPONENT netgen_devel
) )

View File

@ -6,19 +6,19 @@ endif(APPLE)
if(NOT WIN32) if(NOT WIN32)
target_link_libraries(geom2d mesh ${PYTHON_LIBRARIES}) target_link_libraries(geom2d mesh ${PYTHON_LIBRARIES})
install( TARGETS geom2d ${ng_install_dir}) install( TARGETS geom2d ${NG_INSTALL_DIR})
endif(NOT WIN32) endif(NOT WIN32)
if(USE_GUI) if(USE_GUI)
add_library(geom2dvis ${NG_LIB_TYPE} vsgeom2d.cpp) add_library(geom2dvis ${NG_LIB_TYPE} vsgeom2d.cpp)
if(NOT WIN32) if(NOT WIN32)
target_link_libraries(geom2dvis geom2d) target_link_libraries(geom2dvis geom2d)
install( TARGETS geom2dvis ${ng_install_dir}) install( TARGETS geom2dvis ${NG_INSTALL_DIR})
endif(NOT WIN32) endif(NOT WIN32)
endif(USE_GUI) endif(USE_GUI)
install(FILES install(FILES
geom2dmesh.hpp geometry2d.hpp spline2d.hpp geom2dmesh.hpp geometry2d.hpp spline2d.hpp
splinegeometry2.hpp vsgeom2d.hpp splinegeometry2.hpp vsgeom2d.hpp
DESTINATION ${INCDIR}/geom2d COMPONENT netgen_devel DESTINATION ${NG_INSTALL_DIR_INCLUDE}/geom2d COMPONENT netgen_devel
) )

View File

@ -10,5 +10,5 @@ install(FILES
adtree.hpp geom2d.hpp geom3d.hpp geomfuncs.hpp geomobjects2.hpp adtree.hpp geom2d.hpp geom3d.hpp geomfuncs.hpp geomobjects2.hpp
geomobjects.hpp geomops2.hpp geomops.hpp geomtest3d.hpp gprim.hpp geomobjects.hpp geomops2.hpp geomops.hpp geomtest3d.hpp gprim.hpp
splinegeometry.hpp spline.hpp transform3d.hpp splinegeometry.hpp spline.hpp transform3d.hpp
DESTINATION ${INCDIR}/gprim COMPONENT netgen_devel DESTINATION ${NG_INSTALL_DIR_INCLUDE}/gprim COMPONENT netgen_devel
) )

View File

@ -1,10 +1,10 @@
install(FILES nginterface.h nginterface_v2.hpp DESTINATION ${INCDIR} COMPONENT netgen_devel) install(FILES nginterface.h nginterface_v2.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel)
install(FILES install(FILES
acisgeom.hpp csg.hpp geometry2d.hpp gprim.hpp incopengl.hpp acisgeom.hpp csg.hpp geometry2d.hpp gprim.hpp incopengl.hpp
inctcl.hpp incvis.hpp linalg.hpp meshing.hpp myadt.hpp mydefs.hpp inctcl.hpp incvis.hpp linalg.hpp meshing.hpp myadt.hpp mydefs.hpp
mystdlib.h nginterface_v2_impl.hpp occgeom.hpp ngsimd.hpp mystdlib.h nginterface_v2_impl.hpp occgeom.hpp ngsimd.hpp
opti.hpp parallel.hpp parallelinterface.hpp stlgeom.hpp visual.hpp opti.hpp parallel.hpp parallelinterface.hpp stlgeom.hpp visual.hpp
DESTINATION ${INCDIR}/include COMPONENT netgen_devel DESTINATION ${NG_INSTALL_DIR_INCLUDE}/include COMPONENT netgen_devel
) )

View File

@ -12,10 +12,10 @@ if(NOT WIN32)
if(USE_GUI) if(USE_GUI)
target_link_libraries(interface visual) target_link_libraries(interface visual)
endif(USE_GUI) endif(USE_GUI)
install( TARGETS interface ${ng_install_dir}) install( TARGETS interface ${NG_INSTALL_DIR})
endif(NOT WIN32) endif(NOT WIN32)
install(FILES install(FILES
writeuser.hpp writeuser.hpp
DESTINATION ${INCDIR}/interface COMPONENT netgen_devel DESTINATION ${NG_INSTALL_DIR_INCLUDE}/interface COMPONENT netgen_devel
) )

View File

@ -7,5 +7,5 @@ set_target_properties(la PROPERTIES POSITION_INDEPENDENT_CODE ON )
install(FILES install(FILES
densemat.hpp linalg.hpp opti.hpp densemat.hpp linalg.hpp opti.hpp
polynomial.hpp vector.hpp polynomial.hpp vector.hpp
DESTINATION ${INCDIR}/linalg COMPONENT netgen_devel DESTINATION ${NG_INSTALL_DIR_INCLUDE}/linalg COMPONENT netgen_devel
) )

View File

@ -21,6 +21,7 @@ add_library(mesh ${NG_LIB_TYPE}
topology.cpp triarls.cpp validate.cpp bcfunctions.cpp topology.cpp triarls.cpp validate.cpp bcfunctions.cpp
parallelmesh.cpp paralleltop.cpp paralleltop.hpp basegeom.cpp parallelmesh.cpp paralleltop.cpp paralleltop.hpp basegeom.cpp
python_mesh.cpp hexarls.cpp python_mesh.cpp hexarls.cpp
../../ng/onetcl.cpp
${mesh_object_libs} ${mesh_object_libs}
) )
@ -30,7 +31,7 @@ endif(APPLE)
if(NOT WIN32) if(NOT WIN32)
target_link_libraries( mesh ${ZLIB_LIBRARIES} ${MPI_CXX_LIBRARIES} ${PYTHON_LIBRARIES} ${METIS_LIBRARY}) target_link_libraries( mesh ${ZLIB_LIBRARIES} ${MPI_CXX_LIBRARIES} ${PYTHON_LIBRARIES} ${METIS_LIBRARY})
install( TARGETS mesh ${ng_install_dir}) install( TARGETS mesh ${NG_INSTALL_DIR})
endif(NOT WIN32) endif(NOT WIN32)
install(FILES install(FILES
@ -42,5 +43,5 @@ install(FILES
localh.hpp meshclass.hpp meshfunc.hpp meshing2.hpp meshing3.hpp localh.hpp meshclass.hpp meshfunc.hpp meshing2.hpp meshing3.hpp
meshing.hpp meshtool.hpp meshtype.hpp msghandler.hpp paralleltop.hpp meshing.hpp meshtool.hpp meshtype.hpp msghandler.hpp paralleltop.hpp
ruler2.hpp ruler3.hpp specials.hpp topology.hpp validate.hpp ruler2.hpp ruler3.hpp specials.hpp topology.hpp validate.hpp
DESTINATION ${INCDIR}/meshing COMPONENT netgen_devel DESTINATION ${NG_INSTALL_DIR_INCLUDE}/meshing COMPONENT netgen_devel
) )

View File

@ -11,6 +11,8 @@
using namespace netgen; using namespace netgen;
extern const char *ngscript[];
namespace netgen namespace netgen
{ {
extern bool netgen_executable_started; extern bool netgen_executable_started;
@ -51,6 +53,12 @@ static Transformation<3> global_trafo(Vec<3> (0,0,0));
DLL_HEADER void ExportNetgenMeshing(py::module &m) DLL_HEADER void ExportNetgenMeshing(py::module &m)
{ {
m.attr("_netgen_executable_started") = py::cast(netgen::netgen_executable_started); m.attr("_netgen_executable_started") = py::cast(netgen::netgen_executable_started);
string script;
const char ** hcp = ngscript;
while (*hcp)
script += *hcp++;
m.attr("_ngscript") = py::cast(script);
py::class_<NGDummyArgument>(m, "NGDummyArgument") py::class_<NGDummyArgument>(m, "NGDummyArgument")
.def("__bool__", []( NGDummyArgument &self ) { return false; } ) .def("__bool__", []( NGDummyArgument &self ) { return false; } )

View File

@ -10,10 +10,10 @@ add_library(occvis ${NG_LIB_TYPE} vsocc.cpp)
if(NOT WIN32) if(NOT WIN32)
target_link_libraries( occ ${OCC_LIBRARIES} ${PYTHON_LIBRARIES}) target_link_libraries( occ ${OCC_LIBRARIES} ${PYTHON_LIBRARIES})
target_link_libraries( occvis occ ) target_link_libraries( occvis occ )
install( TARGETS occ occvis ${ng_install_dir}) install( TARGETS occ occvis ${NG_INSTALL_DIR})
endif(NOT WIN32) endif(NOT WIN32)
install(FILES install(FILES
occgeom.hpp occmeshsurf.hpp vsocc.hpp occgeom.hpp occmeshsurf.hpp vsocc.hpp
DESTINATION ${INCDIR}/occ COMPONENT netgen_devel DESTINATION ${NG_INSTALL_DIR_INCLUDE}/occ COMPONENT netgen_devel
) )

View File

@ -6,7 +6,7 @@ add_library(stl ${NG_LIB_TYPE}
if(NOT WIN32) if(NOT WIN32)
target_link_libraries( stl mesh ${PYTHON_LIBRARIES}) target_link_libraries( stl mesh ${PYTHON_LIBRARIES})
target_link_libraries( stl ${PYTHON_LIBRARIES}) target_link_libraries( stl ${PYTHON_LIBRARIES})
install( TARGETS stl ${ng_install_dir}) install( TARGETS stl ${NG_INSTALL_DIR})
endif(NOT WIN32) endif(NOT WIN32)
if(USE_GUI) if(USE_GUI)
@ -15,12 +15,12 @@ if(USE_GUI)
) )
if(NOT WIN32) if(NOT WIN32)
target_link_libraries( stlvis stl ) target_link_libraries( stlvis stl )
install( TARGETS stlvis ${ng_install_dir}) install( TARGETS stlvis ${NG_INSTALL_DIR})
endif(NOT WIN32) endif(NOT WIN32)
endif(USE_GUI) endif(USE_GUI)
install(FILES install(FILES
meshstlsurface.hpp stlgeom.hpp stlline.hpp meshstlsurface.hpp stlgeom.hpp stlline.hpp
stltool.hpp stltopology.hpp vsstl.hpp stltool.hpp stltopology.hpp vsstl.hpp
DESTINATION ${INCDIR}/stlgeom COMPONENT netgen_devel DESTINATION ${NG_INSTALL_DIR_INCLUDE}/stlgeom COMPONENT netgen_devel
) )

View File

@ -1,5 +1,5 @@
add_definitions(-DNGINTERFACE_EXPORTS) add_definitions(-DNGINTERFACE_EXPORTS)
install(FILES soldata.hpp DESTINATION ${INCDIR} COMPONENT netgen_devel ) install(FILES soldata.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel )
if(USE_GUI) if(USE_GUI)
set( LIB_VISUAL_SOURCES meshdoc.cpp mvdraw.cpp vsfieldlines.cpp vsmesh.cpp vssolution.cpp importsolution.cpp ) set( LIB_VISUAL_SOURCES meshdoc.cpp mvdraw.cpp vsfieldlines.cpp vsmesh.cpp vssolution.cpp importsolution.cpp )
@ -11,11 +11,11 @@ add_library(visual ${NG_LIB_TYPE} ${LIB_VISUAL_SOURCES})
if(NOT WIN32) if(NOT WIN32)
target_link_libraries( visual ${PYTHON_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ) target_link_libraries( visual ${PYTHON_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} )
install( TARGETS visual ${ng_install_dir}) install( TARGETS visual ${NG_INSTALL_DIR})
endif(NOT WIN32) endif(NOT WIN32)
install(FILES install(FILES
meshdoc.hpp mvdraw.hpp meshdoc.hpp mvdraw.hpp
vispar.hpp visual.hpp vssolution.hpp vispar.hpp visual.hpp vssolution.hpp
DESTINATION ${INCDIR}/visualization COMPONENT netgen_devel DESTINATION ${NG_INSTALL_DIR_INCLUDE}/visualization COMPONENT netgen_devel
) )

View File

@ -1,23 +1,28 @@
set(gui_sources if(USE_INTERNAL_TCL)
add_definitions(-DINTERNAL_TCL_DEFAULT=1)
else()
add_definitions(-DINTERNAL_TCL_DEFAULT=0)
endif()
set(netgen_sources ngappinit.cpp onetcl.cpp)
if(WIN32)
# add icon to netgen executable
enable_language(RC)
set(netgen_sources ${netgen_sources} ../windows/netgen.rc)
# Don't use ccache here due to incompatiblity with the resource compiler
set_directory_properties(PROPERTIES RULE_LAUNCH_COMPILE "")
endif(WIN32)
if(USE_GUI)
add_library(gui SHARED
gui.cpp ngpkg.cpp demoview.cpp parallelfunc.cpp gui.cpp ngpkg.cpp demoview.cpp parallelfunc.cpp
../libsrc/stlgeom/stlpkg.cpp ../libsrc/visualization/visualpkg.cpp ../libsrc/stlgeom/stlpkg.cpp ../libsrc/visualization/visualpkg.cpp
../libsrc/csg/csgpkg.cpp ../libsrc/geom2d/geom2dpkg.cpp ../libsrc/csg/csgpkg.cpp ../libsrc/geom2d/geom2dpkg.cpp
../libsrc/occ/occpkg.cpp ../libsrc/occ/vsocc.cpp ../libsrc/occ/occpkg.cpp ../libsrc/occ/vsocc.cpp
) )
set(netgen_sources ngappinit.cpp onetcl.cpp ) add_executable(netgen ngappinit.cpp onetcl.cpp)
if(USE_GUI)
if(WIN32)
# add icon to netgen executable
enable_language(RC)
set(netgen_sources ${netgen_sources} ../windows/netgen.rc)
# Don't use ccache here due to incompatiblity with the resource compiler
set_directory_properties(PROPERTIES RULE_LAUNCH_COMPILE "")
endif(WIN32)
add_library(gui SHARED ${gui_sources})
add_executable(netgen ${netgen_sources})
target_link_libraries( gui PUBLIC nglib ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${FFMPEG_LIBRARIES} ${X11_X11_LIB} ${OCC_LIBRARIES} ) target_link_libraries( gui PUBLIC nglib ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${FFMPEG_LIBRARIES} ${X11_X11_LIB} ${OCC_LIBRARIES} )
target_link_libraries( gui PRIVATE ${LIBTOGL}) target_link_libraries( gui PRIVATE ${LIBTOGL})
@ -38,8 +43,8 @@ if(USE_GUI)
target_link_libraries( gui PUBLIC mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis ) target_link_libraries( gui PUBLIC mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis )
endif(NOT WIN32) endif(NOT WIN32)
install(TARGETS netgen ${ng_install_dir}) install(TARGETS netgen ${NG_INSTALL_DIR})
install(TARGETS gui ${ng_install_dir}) install(TARGETS gui ${NG_INSTALL_DIR})
if(APPLE) if(APPLE)
set_target_properties(netgen PROPERTIES OUTPUT_NAME netgen) set_target_properties(netgen PROPERTIES OUTPUT_NAME netgen)
@ -59,18 +64,20 @@ if(USE_PYTHON)
set_target_properties( ngpy PROPERTIES SUFFIX ".pyd") set_target_properties( ngpy PROPERTIES SUFFIX ".pyd")
set_target_properties( ngpy PROPERTIES OUTPUT_NAME "libngpy") set_target_properties( ngpy PROPERTIES OUTPUT_NAME "libngpy")
endif() endif()
install(TARGETS ngpy ${ng_install_dir}) set_target_properties(ngpy PROPERTIES INSTALL_RPATH "${NG_RPATH_TOKEN}/../${NETGEN_PYTHON_RPATH}")
install(TARGETS ngpy DESTINATION ${NG_INSTALL_DIR_PYTHON}/${NG_INSTALL_SUFFIX})
endif(USE_PYTHON) endif(USE_PYTHON)
if(USE_GUI) if(USE_GUI)
if(NOT USE_INTERNAL_TCL)
install(FILES install(FILES
dialog.tcl menustat.tcl ngicon.tcl ng.tcl dialog.tcl menustat.tcl ngicon.tcl ng.tcl
ngvisual.tcl sockets.tcl nghelp.tcl ngshell.tcl ngvisual.tcl sockets.tcl nghelp.tcl ngshell.tcl
ngtesting.tcl parameters.tcl variables.tcl csgeom.tcl stlgeom.tcl ngtesting.tcl parameters.tcl variables.tcl csgeom.tcl stlgeom.tcl
occgeom.tcl acisgeom.tcl netgen.ocf occgeom.tcl acisgeom.tcl netgen.ocf drawing.tcl
DESTINATION ${ng_install_dir_bin} COMPONENT netgen) DESTINATION ${NG_INSTALL_DIR_BIN} COMPONENT netgen)
endif()
add_subdirectory(Togl2.1) add_subdirectory(Togl2.1)
install(FILES drawing.tcl DESTINATION ${ng_install_dir_bin} COMPONENT netgen)
endif(USE_GUI) endif(USE_GUI)

View File

@ -7,7 +7,7 @@ endif(APPLE)
if(WIN32) if(WIN32)
add_definitions("-DBUILD_togl -DUNICODE -D_UNICODE -DTOGL_USE_FONTS=0 -DSTDC_HEADERS -DSTDC_HEADER") add_definitions("-DBUILD_togl -DUNICODE -D_UNICODE -DTOGL_USE_FONTS=0 -DSTDC_HEADERS -DSTDC_HEADER")
add_library(togl SHARED togl.c toglProcAddr.c toglStubInit.c) add_library(togl SHARED togl.c toglProcAddr.c toglStubInit.c)
install(TARGETS togl DESTINATION ${ng_install_dir} COMPONENT netgen) install(TARGETS togl DESTINATION ${NG_INSTALL_DIR} COMPONENT netgen)
target_link_libraries(togl ${TCL_LIBRARY} ${TK_LIBRARY}) target_link_libraries(togl ${TCL_LIBRARY} ${TK_LIBRARY})
else(WIN32) else(WIN32)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -Wno-implicit-int") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -Wno-implicit-int")

View File

@ -1,7 +1,9 @@
catch {lappend auto_path $env(NETGENDIR) } catch {lappend auto_path $env(NETGENDIR) }
catch {lappend auto_path $env(NETGENDIR)/../lib } catch {lappend auto_path $env(NETGENDIR)/../lib }
load libgui[info sharedlibextension] gui if {[catch {Ng_GetCommandLineParameter batchmode} result ]} {
load libgui[info sharedlibextension] gui
}
set batchmode [Ng_GetCommandLineParameter batchmode] set batchmode [Ng_GetCommandLineParameter batchmode]
if {$batchmode=="undefined"} { if {$batchmode=="undefined"} {

View File

@ -191,7 +191,7 @@ int main(int argc, char ** argv)
// parse tcl-script // parse tcl-script
int errcode; int errcode;
bool internaltcl = false; bool internaltcl = INTERNAL_TCL_DEFAULT;
if (shellmode) if (shellmode)
internaltcl = false; internaltcl = false;

View File

@ -1,7 +1,9 @@
const char * ngscript[] = {"" const char * ngscript[] = {""
,"catch {lappend auto_path $env(NETGENDIR) }\n" ,"catch {lappend auto_path $env(NETGENDIR) }\n"
,"catch {lappend auto_path $env(NETGENDIR)/../lib }\n" ,"catch {lappend auto_path $env(NETGENDIR)/../lib }\n"
,"if {[catch {Ng_GetCommandLineParameter batchmode} result ]} {\n"
,"load libgui[info sharedlibextension] gui\n" ,"load libgui[info sharedlibextension] gui\n"
,"}\n"
,"set batchmode [Ng_GetCommandLineParameter batchmode]\n" ,"set batchmode [Ng_GetCommandLineParameter batchmode]\n"
,"if {$batchmode==\"undefined\"} {\n" ,"if {$batchmode==\"undefined\"} {\n"
,"if {[catch {package require tkdnd } result ]} {\n" ,"if {[catch {package require tkdnd } result ]} {\n"
@ -5971,4 +5973,5 @@ const char * ngscript[] = {""
,"source startup.tcl }\n" ,"source startup.tcl }\n"
,"catch { source ${ngdir}/demoapp.tcl }\n" ,"catch { source ${ngdir}/demoapp.tcl }\n"
,"catch { source ${ngdir}/dropsexp.tcl }\n" ,"catch { source ${ngdir}/dropsexp.tcl }\n"
, nullptr
}; };

View File

@ -40,5 +40,6 @@ for line in tclfiles["ng.tcl"].split('\n'):
s = ',"' + line.replace('\\', r'\\').replace('"', r'\"') + '\\n"\n' s = ',"' + line.replace('\\', r'\\').replace('"', r'\"') + '\\n"\n'
onetclcpp.write(s) onetclcpp.write(s)
onetclcpp.write('};'+'\n'); onetclcpp.write(', nullptr\n');
onetclcpp.write('};\n');
onetclcpp.close(); onetclcpp.close();

View File

@ -38,5 +38,5 @@ if(USE_PYTHON)
target_link_libraries(nglib ${PYTHON_LIBRARIES}) target_link_libraries(nglib ${PYTHON_LIBRARIES})
endif(USE_PYTHON) endif(USE_PYTHON)
install(TARGETS nglib ${ng_install_dir}) install(TARGETS nglib ${NG_INSTALL_DIR})
install(FILES nglib.h DESTINATION ${INCDIR}/include COMPONENT netgen_devel) install(FILES nglib.h DESTINATION ${NG_INSTALL_DIR_INCLUDE}/include COMPONENT netgen_devel)

View File

@ -1,5 +1,5 @@
install( FILES install( FILES
shaft.geo mesh.py exportNeutral.py shaft.geo mesh.py exportNeutral.py
DESTINATION share/netgen/py_tutorials DESTINATION ${NG_INSTALL_DIR_RES}/${NG_INSTALL_SUFFIX}/py_tutorials
COMPONENT netgen_tutorial COMPONENT netgen_tutorial
) )

View File

@ -1,5 +1,8 @@
install(FILES __init__.py meshing.py csg.py geom2d.py stl.py gui.py configure_file(__init__.py ${CMAKE_CURRENT_BINARY_DIR}/__init__.py @ONLY)
DESTINATION ${PYTHON_PACKAGES_INSTALL_DIR}/netgen
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/__init__.py
meshing.py csg.py geom2d.py stl.py gui.py
DESTINATION ${NG_INSTALL_DIR_PYTHON}/${NG_INSTALL_SUFFIX}
COMPONENT netgen COMPONENT netgen
) )

View File

@ -1,19 +1,13 @@
import os import os
from sys import path import sys
from sys import platform as __platform
if __platform.startswith('linux'): _netgen_bin_dir=os.path.realpath(os.path.join(os.path.dirname(__file__),'..','@NETGEN_PYTHON_RPATH_BIN@'))
_netgen_bin_dir=os.path.realpath(os.path.join(os.path.dirname(__file__),'../../../../bin')) _netgen_lib_dir=os.path.realpath(os.path.join(os.path.dirname(__file__),'..','@NETGEN_PYTHON_RPATH@'))
_netgen_lib_dir=os.path.realpath(os.path.join(os.path.dirname(__file__),'../../../../lib'))
if __platform.startswith('win'):
_netgen_bin_dir=os.path.realpath(os.path.join(os.path.dirname(__file__) + '/../../../bin'))
_netgen_lib_dir=_netgen_bin_dir
if __platform.startswith('darwin'):
_netgen_bin_dir=os.path.realpath(os.path.join(os.path.dirname(__file__) + '/../../../../../MacOS'))
_netgen_lib_dir=_netgen_bin_dir
path.append(_netgen_lib_dir) if sys.platform.startswith('win'):
path.append(_netgen_bin_dir) os.environ['PATH'] += ';'+os.path.realpath(os.path.join(os.path.dirname(__file__),'../../../bin'))
import libngpy del sys
del path del os
from . import libngpy

View File

@ -1,8 +1,7 @@
import libngpy from netgen.libngpy._csg import *
from libngpy._csg import * from netgen.libngpy._meshing import MeshingParameters
from libngpy._meshing import MeshingParameters from netgen.libngpy._meshing import Pnt
from libngpy._meshing import Pnt from netgen.libngpy._meshing import Vec
from libngpy._meshing import Vec
try: try:

View File

@ -1,5 +1,5 @@
from libngpy._geom2d import * from netgen.libngpy._geom2d import *
from libngpy._meshing import * from netgen.libngpy._meshing import *
tmp_generate_mesh = SplineGeometry.GenerateMesh tmp_generate_mesh = SplineGeometry.GenerateMesh

View File

@ -1,16 +1,15 @@
import netgen import netgen
def StartGUI(): def StartGUI():
import os
from tkinter import Tk from tkinter import Tk
from . import _netgen_lib_dir
from . import _netgen_bin_dir
global win global win
win = Tk() win = Tk()
dir_path = os.path.dirname(os.path.realpath(__file__)) win.tk.eval('lappend ::auto_path ' + netgen._netgen_lib_dir)
win.tk.eval("source "+os.path.realpath(os.path.join(_netgen_bin_dir, 'ng.tcl')).replace('\\','/')) win.tk.eval('lappend ::auto_path ' + netgen._netgen_bin_dir)
# load with absolute path to avoid issues on MacOS
win.tk.eval('load '+netgen._netgen_lib_dir.replace('\\','/')+'/libgui[info sharedlibextension] gui')
win.tk.eval( netgen.libngpy._meshing._ngscript)
if not netgen.libngpy._meshing._netgen_executable_started: if not netgen.libngpy._meshing._netgen_executable_started:
StartGUI() StartGUI()

View File

@ -1 +1 @@
from libngpy._meshing import * from netgen.libngpy._meshing import *

View File

@ -1,6 +1,5 @@
import libngpy from netgen.libngpy._stl import *
from libngpy._stl import * from netgen.libngpy._meshing import MeshingParameters
from libngpy._meshing import MeshingParameters
def stl_meshing_func (geom, **args): def stl_meshing_func (geom, **args):

View File

@ -1,4 +1,4 @@
FROM ubuntu:15.10 FROM ubuntu:15.10
MAINTAINER Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> MAINTAINER Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy python3-tk
ADD . /root/src/netgen ADD . /root/src/netgen

View File

@ -1,4 +1,4 @@
FROM ubuntu:16.04 FROM ubuntu:16.04
MAINTAINER Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at> MAINTAINER Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy python3-tk
ADD . /root/src/netgen ADD . /root/src/netgen

11
tests/pytest/test_gui.py Normal file
View File

@ -0,0 +1,11 @@
import netgen
import pytest
def test_gui():
try:
from tkinter import Tk
win = Tk()
except:
pytest.skip("can't create a window")
import netgen.gui

View File

@ -7,6 +7,6 @@ install( FILES
twobricks.geo twocubes.geo twocyl.geo boundarycondition.geo twobricks.geo twocubes.geo twocyl.geo boundarycondition.geo
hinge.stl part1.stl frame.step screw.step hinge.stl part1.stl frame.step screw.step
squarehole.in2d squarecircle.in2d square.in2d squarehole.in2d squarecircle.in2d square.in2d
DESTINATION share/netgen DESTINATION ${NG_INSTALL_DIR_RES}/${NG_INSTALL_SUFFIX}
COMPONENT netgen_tutorial COMPONENT netgen_tutorial
) )