With the changes to
src/3rdParty/salomesmesh/CMakeLists.txt I will describe below, I successfully compiled FreeCAD master on Kubuntu 12.04 with the FREECAD_BUILD_NETGEN option switched on. I use OCE-0.14 and netgen 5.1.
CHANGE 1
I moved all the variables in
include_directories() to the end. Otherwise my build system uses the wrong “utilities.h” header, leading to lots of compilation errors.
Code: Select all
include_directories(
src/SMDS
src/Driver
src/DriverUNV
src/DriverDAT
src/DriverSTL
src/StdMeshers
inc
${CMAKE_BINARY_DIR}/src
${CMAKE_SOURCE_DIR}/src
${CMAKE_CURRENT_BINARY_DIR}
${Boost_INCLUDE_DIRS}
${OCC_INCLUDE_DIR}
${NGLIB_INCLUDE_DIR}
${NETGEN_INCLUDE_DIRS}
)
CHANGE 2
In the section
NETGENPlugin I inserted a COMPILE_FLAGS definition. I omitted the -DOCCGEOMETRY definition to prevent compiler warning about the variable being redifiend.
Code: Select all
################
# NETGENPlugin #
################
…
else(MSVC)
set_target_properties(NETGENPlugin PROPERTIES COMPILE_FLAGS "-DNETGENPLUGIN_EXPORTS -DNO_PARALLEL_THREADS -DNETGEN_V5")
…
With the COMPILE_FLAGS definition above, users with an old netgen version will run into problems. Is this a problem?
For myself, I prefer to use a current version of netgen, linked to a current version of OCE. Building OCE is straight forward. Building netgen is a bit tricky but not too complicated (see notes below).
CHANGE 3
FreeCAD compiles without the next change. However, without that change, I get the warning "sh: 1: SMDS_MemoryLimit: not found" on the console when meshing a geometry. Therefore, I added the following section to CMakeLists.txt.
Note: The conditionals for MSVC and MINGW are an untested guess. Especially, I am unsure about the DEBUG_OUTPUT_NAME.
Code: Select all
############################
# SMDS_MemoryLimit Utility #
############################
SET(SMDS_MemoryLimit_SRCS
src/SMDS/SMDS_MemoryLimit.cpp
)
add_executable(SMDS_MemoryLimit ${SMDS_MemoryLimit_SRCS})
# Note this is IDE specific, not necessarily platform specific
if(MSVC)
set_target_properties(SMDS_MemoryLimit PROPERTIES OUTPUT_NAME "SMDS_MemoryLimit")
set_target_properties(SMDS_MemoryLimit PROPERTIES DEBUG_OUTPUT_NAME "SMDS_MemoryLimit")
# dirty hack to avoid Debug/Release subdirectory
set_target_properties(FreeCADMainCmd PROPERTIES PREFIX "../")
set_target_properties(FreeCADMainCmd PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
elseif(MINGW)
set_target_properties(SMDS_MemoryLimit PROPERTIES OUTPUT_NAME "SMDS_MemoryLimit")
set_target_properties(SMDS_MemoryLimit PROPERTIES DEBUG_OUTPUT_NAME "SMDS_MemoryLimit")
set_target_properties(FreeCADMainCmd PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
else(MSVC)
set_target_properties(SMDS_MemoryLimit PROPERTIES OUTPUT_NAME "SMDS_MemoryLimit")
set_target_properties(SMDS_MemoryLimit PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set_target_properties(SMDS_MemoryLimit PROPERTIES INSTALL_RPATH ${INSTALL_RPATH})
endif(MSVC)
NOTES ABOUT NETGEN
I use netgen from the sourceforge repository (svn checkout svn://svn.code.sf.net/p/netgen-mesher/code netgen-mesher-code). For the following description, the base directory is branches/netgen-5.1.
First, some modifications of the source are required:
In libsrc/occ/Partition_Inter3d.cxx and libsrc/occ/Partition_Splitter.cxx the lines with the comment “# V6.3” must be commented out and the lines with the comment “# V6.5” must be uncommented.
In libsrc/occ/Partition_Loop2d.cxx I have inserted the following lines just after the file header:
Next, a symbolic link must be defined:
Code: Select all
# cd /MY_PREFIX/include/oce
# ln -s . inc
Then we can compile netgen:
Code: Select all
# autoreconf --install
# mkdir build
# cd build
# ../configure --disable-gui --prefix=MY_PREFIX –includedir=/MY_PREFIX/include/netgen --with-occ=/MY_PREFIX/include/oce LDFLAGS=-L/MY_PREFIX/lib
# make -j8 all install
Note: The FreeCAD CMake Variable NETGEN_INCLUDE_DIR must correspond to the --includedir option defined above.
REMARKS ABOUT CMake VARIABLES
To compile FreeCAD, the following variables must point to subdirectories within the netgen source tree (these headers are not part of the netgen dev package, these header are not installed to “include” when compiling and installing netgen using “make all install”)
NETGEN_DIR_csg = NETGEN_SOURCE/libsrc/csg
NETGEN_DIR_gen = NETGEN_SOURCE/libsrc/general
NETGEN_DIR_geom2d = NETGEN_SOURCE/libsrc/geom2d
NETGEN_DIR_gprim = NETGEN_SOURCE/libsrc/gprim
NETGEN_DIR_la = NETGEN_SOURCE/libsrc/linalg
NETGEN_DIR_mesh = NETGEN_SOURCE/libsrc/meshing
NETGEN_DIR_occ = NETGEN_SOURCE/libsrc/occ
NETGEN_DIR_stlgeom = NETGEN_SOURCE/libsrc/stlgeom