diff --git a/README.md b/README.md index 5621374c64..3bef0684e1 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,9 @@ Dependencies Building IfcOpenShell --------------------- + +**Note:** The path where the source code is cloned to can contain spaces but non-ASCII characters are very likely to cause problems with the build. + ### Compiling on Windows The preferred way to fetch and build this project's dependencies is to use the build scripts in win/ folder. **See [win/readme.md] for more information**. @@ -53,9 +56,8 @@ As the scripts default to using the `RelWithDebInfo` configuration, and a freshl to `Debug`, make sure to switch the used build configuration. Build the `INSTALL` project (right-click -> Project Only) to deploy the headers and binaries into a single location if wanted/needed. -Alternatively, one can use the utility batch files to build and install the project easily from the command-line: - - > build-ifcopenshell.bat +Alternatively, one can use the utility batch file(s) to build and install the project easily from the command-line +(installing a project will build it also, if required): > install-ifcopenshell.bat #### Using MSYS2 + MinGW @@ -65,7 +67,6 @@ Start the MSYS2 Shell and then: $ cd IfcOpenShell/win $ ./build-deps.sh $ ./run-cmake.sh - $ ./build-ifcopenshell.sh $ ./install-ifcopenshell.sh #### Using Bash on Ubuntu on Windows @@ -79,16 +80,16 @@ The following instructions are for Ubuntu, modify as required for other operatin can be experimented with and studied for pointers for other operating systems, but note that this script is not currently meant to be used for a typical IfcOpenShell workspace setup. -Install most of the prerequisites and dependencies: +**1)** Install most of the prerequisites and dependencies: $ sudo apt-get install git cmake gcc g++ libboost-all-dev libicu-dev -There might be an Open CASCADE package in your operating system's software repository (see http://opencascade.org -for additional information): +**2a)** Either use an Open CASCADE package from your operating system's software repository (see http://opencascade.org +for additional information) $ sudo apt-get install liboce-foundation-dev liboce-modeling-dev liboce-ocaf-dev liboce-visualization-dev liboce-ocaf-lite-dev -If not, you will need to compile Open CASCADE yourself (note that the build takes a long time): +**2b)** or (if not available, or the latest code is wanted) compile Open CASCADE yourself (note that the build takes a long time): $ sudo apt-get install libftgl-dev libtbb2 libtbb-dev libgl1-mesa-dev libfreetype6-dev $ git clone https://github.com/tpaviot/oce.git @@ -98,7 +99,7 @@ If not, you will need to compile Open CASCADE yourself (note that the build take $ make -j $ sudo make install -For building IfcConvert with COLLADA (.dae) support (on by default), OpenCOLLADA is needed: +**3)** For building IfcConvert with COLLADA (.dae) support (on by default), OpenCOLLADA is needed: $ sudo apt-get install libpcre3-dev $ git clone https://github.com/KhronosGroup/OpenCOLLADA.git @@ -110,11 +111,11 @@ For building IfcConvert with COLLADA (.dae) support (on by default), OpenCOLLADA $ make -j $ sudo make install -For building the IfcPython wrapper (on by default), SWIG and Python development are needed, if not already available: +**4)** For building the IfcPython wrapper (on by default), SWIG and Python development are needed, if not already available: $ sudo apt-get install python-all-dev swig -To build IfcOpenShell please take the following steps. Alternatively use environment variables for setting the +**5)** To build IfcOpenShell please take the following steps. Alternatively use environment variables for setting the dependencies' paths. `OCC_INCLUDE_DIR` might be needed to set also. `OPENCOLLADA_INCLUDE_DIR` and `OPENCOLLADA_LIBRARY_DIR` (and potentially `PCRE_LIBRARY_DIR`) are needed if building with COLLADA support. (`-DCOLLADA_SUPPORT=0` disables it). @@ -128,7 +129,7 @@ dependencies' paths. `OCC_INCLUDE_DIR` might be needed to set also. `OPENCOLLADA If all worked out correctly you can now use IfcOpenShell. See the examples below. -Install the project if wanted: +**6)** Install the project if wanted: $ sudo make install diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 380c6b757a..187a0916e5 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -118,7 +118,7 @@ MESSAGE(STATUS "Boost libraries found in ${Boost_LIBRARY_DIRS}") # Usage: # set(SOME_LIRARIES foo bar) -# add_debug_variants(SOME_LIRARIES "${SOME_LIRARIES}" "d") +# add_debug_variants(SOME_LIRARIES "${SOME_LIRARIES}" d) # "foo bar" -> "optimized foo debug food optimized bar debug bard" # or # set(SOME_LIRARIES path/foo.lib) @@ -128,19 +128,24 @@ MESSAGE(STATUS "Boost libraries found in ${Boost_LIBRARY_DIRS}") # make sure the lib variable ends with not just contains it. function(add_debug_variants NAME LIBRARIES POSTFIX) set(LIBRARIES_STR "${LIBRARIES}") - set(LIBRARIES "") + # the result, "optimized debug ", needs to be a list instead of a string foreach(lib ${LIBRARIES_STR}) - if("${lib}" MATCHES ".lib") + list(APPEND LIBRARIES optimized) + if ("${lib}" MATCHES ".lib") string(REPLACE ".lib" "" lib ${lib}) - set(LIBRARIES "${LIBRARIES} optimized ${lib}.lib") - set(LIBRARIES "${LIBRARIES} debug ${lib}${POSTFIX}.lib") + list(APPEND LIBRARIES ${lib}.lib) else() - set(LIBRARIES "${LIBRARIES} optimized ${lib}") - set(LIBRARIES "${LIBRARIES} debug ${lib}${POSTFIX}") + list(APPEND LIBRARIES ${lib}) + endif() + + list(APPEND LIBRARIES debug) + if ("${lib}" MATCHES ".lib") + string(REPLACE ".lib" "" lib ${lib}) + list(APPEND LIBRARIES ${lib}${POSTFIX}.lib) + else() + list(APPEND LIBRARIES ${lib}${POSTFIX}) endif() endforeach() - string(STRIP ${LIBRARIES} LIBRARIES) # leading and trailing whitespace cause confusion - separate_arguments(LIBRARIES) # "optimized debug " needs to be a list instead of a string set(${NAME} ${LIBRARIES} PARENT_SCOPE) endfunction() @@ -190,7 +195,7 @@ endforeach() if(MSVC) add_definitions(-DHAVE_NO_DLL) - add_debug_variants(OPENCASCADE_LIBRARIES "${OPENCASCADE_LIBRARIES}" "d") + add_debug_variants(OPENCASCADE_LIBRARIES "${OPENCASCADE_LIBRARIES}" d) endif() IF(UNICODE_SUPPORT) @@ -216,7 +221,7 @@ IF(UNICODE_SUPPORT) IF(WIN32) FIND_LIBRARY(icudt NAMES icudt PATHS ${ICU_LIBRARY_DIR} NO_DEFAULT_PATH) SET(ICU_LIBRARIES ${icu} ${icudt}) - add_debug_variants(ICU_LIBRARIES "${ICU_LIBRARIES}" "d") + add_debug_variants(ICU_LIBRARIES "${ICU_LIBRARIES}" d) # TODO MinGW build would appear to be using dynamic ICU regardless of this definition. ADD_DEFINITIONS(-DU_STATIC_IMPLEMENTATION) # required for static ICU ELSE() @@ -286,7 +291,7 @@ IF(COLLADA_SUPPORT) endif() IF(MSVC) - add_debug_variants(OPENCOLLADA_LIBRARIES "${OPENCOLLADA_LIBRARIES}" "d") + add_debug_variants(OPENCOLLADA_LIBRARIES "${OPENCOLLADA_LIBRARIES}" d) ENDIF() ELSE() MESSAGE(FATAL_ERROR "COLLADA_SUPPORT enabled, but unable to find OpenCOLLADA. Disable COLLADA_SUPPORT or fix OpenCOLLADA paths to proceed.") diff --git a/win/build-deps.cmd b/win/build-deps.cmd index 0509a75cb8..9dea0355d2 100644 --- a/win/build-deps.cmd +++ b/win/build-deps.cmd @@ -60,8 +60,8 @@ IF NOT "!BUILD_TYPE!"=="Build" IF NOT "!BUILD_TYPE!"=="Rebuild" IF NOT "!BUILD_T ) :: Make sure deps and install folders exists. -IF NOT EXIST %DEPS_DIR%. mkdir %DEPS_DIR% -IF NOT EXIST %INSTALL_DIR%. mkdir %INSTALL_DIR% +IF NOT EXIST "%DEPS_DIR%". mkdir "%DEPS_DIR%" +IF NOT EXIST "%INSTALL_DIR%". mkdir "%INSTALL_DIR%" :: If we use VS2008, framework path (for MSBuild) may not be correctly set. Manually attempt to add in that case IF %VS_VER%==2008 set PATH=C:\Windows\Microsoft.NET\Framework\v3.5;%PATH% @@ -134,7 +134,7 @@ echo Build started at %START_TIME%. set BUILD_STARTED=TRUE echo. -cd %DEPS_DIR% +cd "%DEPS_DIR%" :: Note all of the depedencies have approriate label so that user can easily skip something if wanted :: by modifying this file and using goto. @@ -145,7 +145,7 @@ set DEPENDENCY_NAME=Boost %BOOST_VERSION% set DEPENDENCY_DIR="%DEPS_DIR%\boost" :: Version string with underscores instead of dots. set BOOST_VER=%BOOST_VERSION:.=_% -set BOOST_ROOT=%DEPS_DIR%\boost +REM set BOOST_ROOT=%DEPS_DIR%\boost REM set BOOST_INCLUDEDIR=%DEPS_DIR%\boost set BOOST_LIBRARYDIR=%DEPS_DIR%\boost\stage\%VS_PLATFORM%\lib :: NOTE Also zip download exists, if encountering problems with 7z for some reason. @@ -383,7 +383,7 @@ IF NOT %ERRORLEVEL%==0 GOTO :Error call :ExtractArchive %SWIG_ZIP% "%DEPS_DIR%" "%DEPS_DIR%\swigwin" IF NOT %ERRORLEVEL%==0 GOTO :Error IF EXIST "%DEPS_DIR%\swigwin-%SWIG_VERSION%". ( - pushd %DEPS% + pushd "%DEPS_DIR%" ren swigwin-%SWIG_VERSION% swigwin popd ) @@ -391,7 +391,7 @@ IF EXIST "%DEPS_DIR%\swigwin\". robocopy "%DEPS_DIR%\swigwin" "%INSTALL_DIR%\swi :Successful echo. -call %~dp0\utils\cecho.cmd 0 10 "%PROJECT_NAME% dependencies built." +call "%~dp0\utils\cecho.cmd" 0 10 "%PROJECT_NAME% dependencies built." set IFCOS_SCRIPT_RET=0 goto :Finish @@ -400,7 +400,7 @@ echo. call :PrintUsage :Error echo. -call %~dp0\utils\cecho.cmd 0 12 "An error occurred! Aborting!" +call "%~dp0\utils\cecho.cmd" 0 12 "An error occurred! Aborting!" set IFCOS_SCRIPT_RET=1 goto :Finish @@ -423,20 +423,20 @@ echo. echo Build ended at %END_TIME%. Time elapsed %hh%:%mm%:%ss%.%cc%. :BuildTimeSkipped set PATH=%ORIGINAL_PATH% -cd %~dp0 +cd "%~dp0" exit /b %IFCOS_SCRIPT_RET% ::::::::::::::::::::::::::::::::::::: Subroutines ::::::::::::::::::::::::::::::::::::: -:: DownloadFile - Downloads a file using wget +:: DownloadFile - Downloads a file using PowerShell :: Params: %1 url, %2 destinationDir, %3 filename :DownloadFile -pushd %2 -IF NOT EXIST "%3". ( - call cecho.cmd 0 13 "Downloading %DEPENDENCY_NAME% into %2." +pushd "%2" +if not exist "%~3". ( + call cecho.cmd 0 13 "Downloading %DEPENDENCY_NAME% into %~2." powershell -Command "$webClient = new-object System.Net.WebClient; $webClient.DownloadFile('%1', '%3')" REM Old wget version in case someone has problem with PowerShell: wget --no-check-certificate %1 -) ELSE ( +) else ( call cecho.cmd 0 13 "%DEPENDENCY_NAME% already downloaded. Skipping." ) set RET=%ERRORLEVEL% @@ -446,11 +446,11 @@ exit /b %RET% :: ExtractArchive - Extracts an archive file using 7-zip :: Params: %1 filename, %2 destinationDir, %3 dirAfterExtraction :ExtractArchive -IF NOT EXIST "%3". ( - call cecho.cmd 0 13 "Extracting %DEPENDENCY_NAME% into %2." +if not exist "%~3". ( + call cecho.cmd 0 13 "Extracting %DEPENDENCY_NAME% into %~2." 7za x %1 -y -o%2 -) ELSE ( - call cecho.cmd 0 13 "%DEPENDENCY_NAME% already extracted into %3. Skipping." +) else ( + call cecho.cmd 0 13 "%DEPENDENCY_NAME% already extracted into %~3. Skipping." ) exit /b %ERRORLEVEL% @@ -458,12 +458,12 @@ exit /b %ERRORLEVEL% :: Params: %1 gitUrl, %2 destDir :: F.ex. call :GitCloneRepository https://github.com/KhronosGroup/OpenCOLLADA.git "%DEPS_DIR%\OpenCOLLADA\" :GitCloneOrPullRepository -IF NOT EXIST %2. ( - call cecho.cmd 0 13 "Cloning %DEPENDENCY_NAME% into %2." +if not exist "%~2". ( + call cecho.cmd 0 13 "Cloning %DEPENDENCY_NAME% into %~2." pushd "%DEPS_DIR%" call git clone %1 %2 set RET=%ERRORLEVEL% -) ELSE ( +) else ( call cecho.cmd 0 13 "%DEPENDENCY_NAME% already cloned. Pulling latest changes." pushd %2 call git pull @@ -476,14 +476,14 @@ exit /b %RET% :: Params: %1 gitUrl, %2 destDir, %3 revision :: F.ex. call :GitCloneAndCheckoutRevision https://github.com/KhronosGroup/OpenCOLLADA.git "%DEPENDENCY_DIR%" 064a60b65c2c31b94f013820856bc84fb1937cc6 :GitCloneAndCheckoutRevision -IF NOT EXIST "%2". ( - call cecho.cmd 0 13 "Cloning %DEPENDENCY_NAME% into %2." +if not exist "%~2". ( + call cecho.cmd 0 13 "Cloning %DEPENDENCY_NAME% into %~2." pushd "%DEPS_DIR%" call git clone %1 %2 set RET=%ERRORLEVEL% if not %RET%==0 exit /b %RET% popd -) ELSE ( +) else ( call cecho.cmd 0 13 "%DEPENDENCY_NAME% already cloned." set RET=0 ) @@ -515,7 +515,7 @@ exit /b %RET% :: BuildSolution - Builds/Rebuilds/Cleans a solution using MSBuild :: Params: %1 solutioName, %2 configuration :BuildSolution -call cecho.cmd 0 13 "%BUILD_TYPE%ing %2 %DEPENDENCY_NAME%. Please be patient, this will take a while." +call cecho.cmd 0 13 "Building %2 %DEPENDENCY_NAME%. Please be patient, this will take a while." %MSBUILD_CMD% %1 /p:configuration=%2;platform=%VS_PLATFORM% exit /b %ERRORLEVEL% @@ -533,7 +533,7 @@ exit /b %RET% :: PrintUsage - Prints usage information :PrintUsage -call %~dp0\utils\cecho.cmd 0 10 "Requirements for a successful execution:" +call "%~dp0\utils\cecho.cmd" 0 10 "Requirements for a successful execution:" echo 1. Install PowerShell (preinstalled in Windows ^>= 7) and make sure 'powershell' is accessible from PATH. echo - https://support.microsoft.com/en-us/kb/968929 echo 2. Install Git and make sure 'git' is accessible from PATH. diff --git a/win/build-ifcopenshell.bat b/win/build-ifcopenshell.bat index f2db83cdf4..7f8233cb54 100644 --- a/win/build-ifcopenshell.bat +++ b/win/build-ifcopenshell.bat @@ -67,7 +67,7 @@ goto :End :Error echo. -call %~dp0\utils\cecho.cmd 0 12 "%VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME% build failed!" +call "%~dp0\utils\cecho.cmd" 0 12 "%VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME% build failed!" %IFCOS_PAUSE_ON_ERROR% set IFCOS_SCRIPT_RET=1 diff --git a/win/install-ifcopenshell.bat b/win/install-ifcopenshell.bat index 35e821ff9c..592ec85b89 100644 --- a/win/install-ifcopenshell.bat +++ b/win/install-ifcopenshell.bat @@ -66,7 +66,7 @@ goto :End :Error echo. -call %~dp0\utils\cecho.cmd 0 12 "%VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME% installation failed!" +call "%~dp0\utils\cecho.cmd" 0 12 "%VS_PLATFORM% %BUILD_CFG% %PROJECT_NAME% installation failed!" %IFCOS_PAUSE_ON_ERROR% set IFCOS_SCRIPT_RET=1 diff --git a/win/run-cmake.bat b/win/run-cmake.bat index d5d096667d..1e62f6a61a 100644 --- a/win/run-cmake.bat +++ b/win/run-cmake.bat @@ -33,7 +33,7 @@ for /f "tokens=*" %%f in ('dir BuildDepsCache-*.txt /o:-n /t:a /b') do ( set GENERATOR=%1 if (%1)==() ( if not defined GEN_SHORTHAND ( - echo BuildDepsCache file does and/or GEN_SHORTHAND missing from it. Run build-deps.cmd to create it. + echo BuildDepsCache file does not exist and/or GEN_SHORTHAND missing from it. Run build-deps.cmd to create it. set IFCOS_PAUSE_ON_ERROR=pause goto :Error ) @@ -59,6 +59,7 @@ IF NOT EXIST ..\%BUILD_DIR%. mkdir ..\%BUILD_DIR% pushd ..\%BUILD_DIR% set BOOST_ROOT=%DEPS_DIR%\boost +REM set BOOST_INCLUDEDIR=%DEPS_DIR%\boost\boost set BOOST_LIBRARYDIR=%DEPS_DIR%\boost\stage\vs%VS_VER%-%VS_PLATFORM%\lib set ICU_INCLUDE_DIR=%INSTALL_DIR%\icu\include set ICU_LIBRARY_DIR=%INSTALL_DIR%\icu\lib @@ -113,7 +114,7 @@ goto :Finish :Error echo. -call %~dp0\utils\cecho.cmd 0 12 "An error occurred! Aborting!" +call "%~dp0\utils\cecho.cmd" 0 12 "An error occurred! Aborting!" %IFCOS_PAUSE_ON_ERROR% set IFCOS_SCRIPT_RET=1 goto :Finish diff --git a/win/set-python-to-path.bat b/win/set-python-to-path.bat index b40e46913c..a76393895d 100644 --- a/win/set-python-to-path.bat +++ b/win/set-python-to-path.bat @@ -22,13 +22,13 @@ @echo off set TARGET_ARCH=%1 if "%TARGET_ARCH%"=="" set TARGET_ARCH=x64 -if not exist %~dp0BuildDepsCache-%TARGET_ARCH%.txt. ( +if not exist "%~dp0BuildDepsCache-%TARGET_ARCH%.txt". ( echo %~dp0BuildDepsCache-%TARGET_ARCH%.txt does not exist goto :EOF ) -for /f "delims== tokens=1,2" %%G in (%~dp0BuildDepsCache-%TARGET_ARCH%.txt) do set %%G=%%H +for /f "delims== tokens=1,2" %%G in ("%~dp0BuildDepsCache-%TARGET_ARCH%.txt") do set %%G=%%H if not defined PYTHONHOME ( - echo PYTHONHOME PYTHONHOME not defined + echo PYTHONHOME not defined goto :EOF )