mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
Let CMake find python interpreter for schema compilation and installation dir
Remove unused compiled schema in cpp installation target
This commit is contained in:
+28
-32
@@ -288,32 +288,32 @@ function(files_for_ifc_version IFC_VERSION RESULT_NAME)
|
||||
endfunction()
|
||||
|
||||
if(COMPILE_SCHEMA)
|
||||
find_package(PythonInterp)
|
||||
|
||||
IF(NOT PYTHONINTERP_FOUND)
|
||||
MESSAGE(FATAL_ERROR "A Python interpreter is necessary when COMPILE_SCHEMA is enabled. Disable COMPILE_SCHEMA or fix Python paths to proceed.")
|
||||
ENDIF()
|
||||
|
||||
set(IFC_RELEASE_NOT_USED "2x3" "4")
|
||||
|
||||
if(PYTHON_EXECUTABLE)
|
||||
set(PYTHON_EXECUTABLE_USED ${PYTHON_EXECUTABLE})
|
||||
else()
|
||||
set(PYTHON_EXECUTABLE_USED "python")
|
||||
endif()
|
||||
|
||||
# Install pyparsing if necessary
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE_USED} -m pip "list" OUTPUT_VARIABLE PYTHON_PACKAGE_LIST)
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip "list" OUTPUT_VARIABLE PYTHON_PACKAGE_LIST)
|
||||
string(FIND "${PYTHON_PACKAGE_LIST}" pyparsing PYPARSING_FOUND)
|
||||
if ("${PYPARSING_FOUND}" STREQUAL "-1")
|
||||
message(STATUS "Installing pyparsing")
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE_USED} -m pip "install" --user pyparsing)
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip "install" --user pyparsing)
|
||||
else()
|
||||
message(STATUS "Python interpreter with pyparsing found")
|
||||
endif()
|
||||
|
||||
# Bootstrap the parser
|
||||
message(STATUS "Compiling schema, this will take a while...")
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE_USED} bootstrap.py express.bnf
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} bootstrap.py express.bnf
|
||||
WORKING_DIRECTORY ../src/ifcexpressparser
|
||||
OUTPUT_FILE express_parser.py)
|
||||
|
||||
# Generate code
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE_USED} ../ifcexpressparser/express_parser.py ../../${COMPILE_SCHEMA}
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} ../ifcexpressparser/express_parser.py ../../${COMPILE_SCHEMA}
|
||||
WORKING_DIRECTORY ../src/ifcparse
|
||||
OUTPUT_VARIABLE COMPILED_SCHEMA_NAME)
|
||||
|
||||
@@ -334,28 +334,31 @@ else()
|
||||
endif()
|
||||
|
||||
# IfcParse
|
||||
file(GLOB CPP_FILES ../src/ifcparse/*.cpp)
|
||||
file(GLOB H_FILES ../src/ifcparse/*.h)
|
||||
set(SOURCE_FILES ${CPP_FILES} ${H_FILES})
|
||||
file(GLOB IFCPARSE_H_FILES ../src/ifcparse/*.h)
|
||||
file(GLOB IFCPARSE_CPP_FILES ../src/ifcparse/*.cpp)
|
||||
|
||||
foreach(IFC_RELEASE ${IFC_RELEASE_NOT_USED})
|
||||
files_for_ifc_version(${IFC_RELEASE} SOURCE_FILES_NOT_USED)
|
||||
foreach(SOURCE_FILE ${SOURCE_FILES_NOT_USED})
|
||||
list(REMOVE_ITEM SOURCE_FILES ${SOURCE_FILE})
|
||||
list(REMOVE_ITEM IFCPARSE_CPP_FILES ${SOURCE_FILE})
|
||||
list(REMOVE_ITEM IFCPARSE_H_FILES ${SOURCE_FILE})
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
ADD_LIBRARY(IfcParse STATIC ${SOURCE_FILES})
|
||||
set(IFCPARSE_FILES ${IFCPARSE_CPP_FILES} ${IFCPARSE_H_FILES})
|
||||
|
||||
ADD_LIBRARY(IfcParse STATIC ${IFCPARSE_FILES})
|
||||
|
||||
IF(UNICODE_SUPPORT)
|
||||
TARGET_LINK_LIBRARIES(IfcParse ${ICU_LIBRARIES})
|
||||
ENDIF()
|
||||
|
||||
# IfcGeom
|
||||
file(GLOB CPP_FILES ../src/ifcgeom/*.cpp)
|
||||
file(GLOB H_FILES ../src/ifcgeom/*.h)
|
||||
set(SOURCE_FILES ${CPP_FILES} ${H_FILES})
|
||||
ADD_LIBRARY(IfcGeom STATIC ${SOURCE_FILES})
|
||||
file(GLOB IFCGEOM_H_FILES ../src/ifcgeom/*.h)
|
||||
file(GLOB IFCGEOM_CPP_FILES ../src/ifcgeom/*.cpp)
|
||||
|
||||
set(IFCGEOM_FILES ${IFCGEOM_CPP_FILES} ${IFCGEOM_H_FILES})
|
||||
ADD_LIBRARY(IfcGeom STATIC ${IFCGEOM_FILES})
|
||||
|
||||
TARGET_LINK_LIBRARIES(IfcGeom IfcParse)
|
||||
|
||||
@@ -366,10 +369,10 @@ if(NOT WIN32)
|
||||
LINK_DIRECTORIES(${LINK_DIRECTORIES} /usr/lib /usr/lib64 /usr/local/lib /usr/local/lib64)
|
||||
endif()
|
||||
|
||||
file(GLOB CPP_FILES ../src/ifcconvert/*.cpp)
|
||||
file(GLOB H_FILES ../src/ifcconvert/*.h)
|
||||
set(SOURCE_FILES ${CPP_FILES} ${H_FILES})
|
||||
ADD_EXECUTABLE(IfcConvert ${SOURCE_FILES})
|
||||
file(GLOB IFCCONVERT_CPP_FILES ../src/ifcconvert/*.cpp)
|
||||
file(GLOB IFCCONVERT_H_FILES ../src/ifcconvert/*.h)
|
||||
set(IFCCONVERT_FILES ${IFCCONVERT_CPP_FILES} ${IFCCONVERT_H_FILES})
|
||||
ADD_EXECUTABLE(IfcConvert ${IFCCONVERT_FILES})
|
||||
|
||||
# Make sure cross-referenced symbols between static OCC libraries get
|
||||
# resolved. Also add thread and rt libraries.
|
||||
@@ -397,15 +400,8 @@ IF(BUILD_EXAMPLES)
|
||||
ADD_SUBDIRECTORY(../src/examples examples)
|
||||
ENDIF()
|
||||
|
||||
# TODO QtViewer is deprecated ATM as it uses the 0.4 API
|
||||
# IF(BUILD_QTVIEWER)
|
||||
# ADD_SUBDIRECTORY(../src/qtviewer qtviewer)
|
||||
# ENDIF()
|
||||
|
||||
# CMake installation targets
|
||||
FILE(GLOB include_files_geom ../src/ifcgeom/*.h)
|
||||
FILE(GLOB include_files_parse ../src/ifcparse/*.h)
|
||||
INSTALL(FILES ${include_files_geom} DESTINATION include/ifcgeom)
|
||||
INSTALL(FILES ${include_files_parse} DESTINATION include/ifcparse)
|
||||
INSTALL(FILES ${IFCPARSE_H_FILES} DESTINATION include/ifcparse)
|
||||
INSTALL(FILES ${IFCGEOM_H_FILES} DESTINATION include/ifcgeom)
|
||||
INSTALL(TARGETS IfcConvert IfcGeomServer DESTINATION bin)
|
||||
INSTALL(TARGETS IfcParse IfcGeom DESTINATION lib)
|
||||
|
||||
Reference in New Issue
Block a user