# Copyright (2010) Thomas Paviot, tpaviot@gmail.com. # # This file is distributed under the terms of the OpenCASCADE Technology Public License 6.3, August 2008 # Complete text of this license can be read online: http://www.opencascade.org/getocc/license/ # # REQUIREMENTS: this script needs CMake 2.6 or higher. Downloads are available at http://www.cmake.org # How to build OpenCASCADE using CMake under Unix (Linux, Darwin etc.)? # 1. Copy this file, as-is, to the /ros folder # 2. cd ros # 3. cmake . # 4. make # How to build OpenCASCADE using CMake under Windows (Linux, Darwin etc.)? # 1. Copy this file, as-is, to the /ros folder # 2. Launch the cmake-gui, and select the /ros folder # 3. You can choose whatever you want as an install directory # 4. Click 'Configure' # 5. Choose your generator # 6. When configure is achived, you can change the variable with a red background # 7. Click 'Generate' # 8. From your IDE, open the generated makefile and run the compilation. PROJECT(OpenCASCADE) SET(OpenCASCADE_VERSION_MAJOR 6) SET(OpenCASCADE_VERSION_MINOR 3) SET(OpenCASCADE_VERSION_PATCH 0) CMAKE_MINIMUM_REQUIRED(VERSION 2.6) SET(CMAKE_BUILD_TYPE "Release") # By default, build in release mode SET(BUILD_SHARED_LIBS ON) # Always build shared libraries INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) INCLUDE_DIRECTORIES(inc) #################################### # Looking for required packages # #################################### FIND_PACKAGE(OpenGL) FIND_PACKAGE(X11) FIND_PACKAGE(Tcl) FIND_PACKAGE(Java) # TODO: add all required other external packages ################################################### # Check required headers, functions and libraries # ################################################### IF (NOT WIN32) # Check headers INCLUDE(CheckIncludeFile) INCLUDE(CheckIncludeFiles) CHECK_INCLUDE_FILE("alloca.h" HAVE_ALLOCA_H) CHECK_INCLUDE_FILE("float.h" HAVE_FLOAT_H) CHECK_INCLUDE_FILE("iomanip.h" HAVE_IOMANIP_H) # Check library functions INCLUDE(CheckFunctionExists) CHECK_FUNCTION_EXISTS(alloca HAVE_ALLOCA) CHECK_FUNCTION_EXISTS(memcmp HAVE_MEMCMP) CHECK_FUNCTION_EXISTS(signal HAVE_SIGNAL) CHECK_FUNCTION_EXISTS(gethostname HAVE_GETHOSTNAME) CHECK_FUNCTION_EXISTS(putenv HAVE_PUTENV) CHECK_FUNCTION_EXISTS(re_comp HAVE_RE_COMP) CHECK_FUNCTION_EXISTS(regcomp HAVE_REGCOMP) CHECK_FUNCTION_EXISTS(strcspn HAVE_STRCSPN) CHECK_FUNCTION_EXISTS(strdup HAVE_STRDUP) CHECK_FUNCTION_EXISTS(strtol HAVE_STRTOL) CHECK_FUNCTION_EXISTS(statfs HAVE_STATFS) CHECK_FUNCTION_EXISTS(statvfs HAVE_STATVFS) CHECK_FUNCTION_EXISTS(finite HAVE_FINITE) # TODO: check all headers/functions/libraries that are checked in configure.ac original OCC script # TODO: generate the config.h file from these checks ENDIF(NOT WIN32) ############################ # Check 32/64 bit platform # ############################ IF (${CMAKE_SIZEOF_VOID_P} MATCHES "8") # It is 64bit, otherwise 32 bit systems match 4 ADD_DEFINITIONS(-D_OCC64) MESSAGE("-- Build 64bit") SET(MODE "64bit") SET(BIT 64) ELSE (${CMAKE_SIZEOF_VOID_P} MATCHES "8") MESSAGE("-- Build 32bit") SET(BIT 32) ENDIF(${CMAKE_SIZEOF_VOID_P} MATCHES "8") # TODO: add optional 32/64 bit compilation mode to overwrite this default setting (one eventually # would like to compile OCC in 32bit mode even on a 64bit machine). ####################################################### # Check platforms - Define specific compilation flags # ####################################################### IF(UNIX) IF(APPLE) ######### MacOSX ########### MESSAGE("-- MacOSX platform detected") SET(PLATFORM Darwin) ADD_DEFINITIONS(-DHAVE_CONFIG_H -DCSFDB -DLIN -DOCC_CONVERT_SIGNALS) ELSE(APPLE) ######### Unix/Linux ########### MESSAGE("-- Unix/Linux platform detected") ADD_DEFINITIONS(-DHAVE_CONFIG_H -DCSFDB -DLIN -DOCC_CONVERT_SIGNALS) SET(PLATFORM Unix) ENDIF(APPLE) ELSE(UNIX) IF(WIN32) ######### Windows ########### MESSAGE("-- Windows system detected") ADD_DEFINITIONS(-DWNT -DWIN32 -D_WINDOWS -DCSFDB) SET(PLATFORM win) ELSE(WIN32) MESSAGE("Unknown platform") ENDIF(WIN32) ENDIF(UNIX) # TODO: better detection of different Unices (Linux, Solaris etc.) # TODO: add CXX compiler flags for each platform ################################################ # Define output path for generated libraries: # # platform/compiler-build_type-bits # # for instance: # # ./win32/bin/vc7.1-release-64 # # ./win32/bin/vc9-debug-32 # # ./Unix/i386-debug-64 # ################################################ IF(WIN32) IF(${MSVC}) # The compiler used is MSVC MESSAGE("Found MSVC compiler: ${MSVC} ${MSVC_VERSION}") SET(LIBRARY_OUTPUT_PATH win${BIT}/${MSVC_VERSION}-${CMAKE_BUILD_TYPE}/bin) ELSE(${MSVC}) SET(LIBRARY_OUTPUT_PATH win${BIT}/bin/${CMAKE_BUILD_TYPE}) ENDIF(${MSVC}) ELSE(WIN32) SET(LIBRARY_OUTPUT_PATH ${PLATFORM}/${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_BUILD_TYPE}-${BIT}) ENDIF(WIN32) MESSAGE("-- output_path: ${LIBRARY_OUTPUT_PATH}") # TODO: under win32/64, dlls and libs should not be in the same path ############################################### # Build the list of all OCC Toolkits to build # ############################################### LIST(APPEND OCC_ToolKits TKernel TKBRep) # TODO: add all OCC Toolkits: TKBRep, TKService etc. #################################################################################### # Define the list of modules of each ToolKit # # The name of this list is ToolKit_MODULES: TKService_MODULES, TKBRep_MODULES etc. # #################################################################################### LIST(APPEND TKernel_MODULES Dico FSD MMgt Message NCollection OSD Plugin Quantity Resource SortTools Standard StdFail Storage TColStd TCollection Units) LIST(APPEND TKBRep_MODULES BRepAdaptor BRepLProp BRepTools BRep TopExp TopoDS) # TODO: for each toolkit (TKService, TKXCAF etc.), build the list of modules ############################################################################### # Dependencies for each ToolKit: a list ToolKit_REQUIRED_LIBRARIES is created # # for each ToolKit # ############################################################################### LIST(APPEND TKernel_REQUIRED_LIBRARIES pthread) # TODO: create this list for all toolkits (TKService_REQUIRED_LIBRARIES, TKBRep_REQUIRED_LIBRARIES etc.) ################################################################################################## # Defining libraries: the algorithm is # # 1. A loop is performed over ToolKit lists. A library is created for each. # # 2. Within each ToolKit, a loop is performed over modules to find source files to compile # ################################################################################################## FOREACH(OCC_ToolKit ${OCC_ToolKits}) SET(CURRENT_TOOLKIT ${OCC_ToolKit}) SET(CURRENT_TOOLKIT_MODULES ${CURRENT_TOOLKIT}_MODULES) MESSAGE("-- Processing ToolKit: ${CURRENT_TOOLKIT}(${${CURRENT_TOOLKIT_MODULES}})") # init CURRENT_TOOLKIT_SOURCE_FILES variable to 0 SET(CURRENT_TOOLKIT_SOURCE_FILES) FOREACH(MODULE ${${CURRENT_TOOLKIT_MODULES}}) #MESSAGE("-- ${MODULE}") # add all .cxx files or each module FILE(GLOB ${MODULE}_source_files src/${MODULE}/*.cxx) # append these source files to the list of source files of the toolkit SET(CURRENT_TOOLKIT_SOURCE_FILES ${CURRENT_TOOLKIT_SOURCE_FILES} ${${MODULE}_source_files}) # required include paths INCLUDE_DIRECTORIES(src/${MODULE}) # location of *.lxx files INCLUDE_DIRECTORIES(drv/${MODULE}) # location of the *.ixx files ENDFOREACH(MODULE ${CURRENT_TOOLKIT_MODULES}) ADD_LIBRARY(${CURRENT_TOOLKIT} SHARED ${CURRENT_TOOLKIT_SOURCE_FILES}) # Set dependencies for thit ToolKit TARGET_LINK_LIBRARIES(${CURRENT_TOOLKIT} ${${CURRENT_TOOLKIT}_REQUIRED_LIBRARIES}) ENDFOREACH(OCC_ToolKit in ${OCC_ToolKits})