QtCreator — сборка и компоновка OpenCascade с помощью CMake ⇐ C++
QtCreator — сборка и компоновка OpenCascade с помощью CMake
I want to build a project that uses OpenCascade. I also want to build all the libraries. It depends on freetype, tcl and tk. So I want to build all these, too. I'm struggling with how to do it properly. I'm using Windows, if that matters. So, before I start fiddling around with trial/error just to get it somehow working, I'd like to ask what's the "proper" way to do this using QtCreator and CMake. Assume, my toolchain(s) are set up properly to build Qt applications.
Assume my sub-folder structure is a fresh download of the libraries:
mylibrary/main.cpp occt-7_8_0/ freetype-2.10.4/ tcl8.5.0/ tk8.5.0/ I don't want to use VTK and my main.cpp might look like:
#include #include
void makeBox(){ gp_Pnt gp1(0,0,0); gp_Pnt gp2(1,1,1); TopoDS_Solid box = BRepPrimAPI_MakeBox(gp1, gp2).Solid(); } And the CMakesList.txt of mylibrary/ is
message("=== Occt wrapper as a lib ===") add_library(mylibrary_lib SHARED) if (CMAKE_COMPILER_IS_GNUCXX) add_compile_options(-Wa,-mbig-obj) endif() if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") endif() # find_package() uses Config.cmake-file in _DIR path find_package(OpenCASCADE REQUIRED) target_include_directories(mylibrary_lib PRIVATE "${OpenCASCADE_INCLUDE_DIR}") # OCC is needed if(NOT OpenCASCADE_FOUND) message(FATAL_ERROR "Cannot build the executable without OpenCASCADE. Please set the variable OpenCASCADE_DIR.") else() message(" found OpenCASCADE " ${OpenCASCADE_VERSION}) # include target_include_directories(mylibrary_lib PUBLIC ${OpenCASCADE_INCLUDE_DIR}) message(" found OpenCASCADE_INCLUDE_DIR: ${OpenCASCADE_INCLUDE_DIR}" ) # link target_link_libraries(mylibrary_lib PUBLIC ${OpenCASCADE_LIBRARIES}) # This should be private! message(" found OpenCASCADE_LIBRARIES: ${OpenCASCADE_LIBRARIES}" ) endif() target_sources(mylibrary_lib PUBLIC "./main.cpp")
Источник: https://stackoverflow.com/questions/781 ... sing-cmake
I want to build a project that uses OpenCascade. I also want to build all the libraries. It depends on freetype, tcl and tk. So I want to build all these, too. I'm struggling with how to do it properly. I'm using Windows, if that matters. So, before I start fiddling around with trial/error just to get it somehow working, I'd like to ask what's the "proper" way to do this using QtCreator and CMake. Assume, my toolchain(s) are set up properly to build Qt applications.
Assume my sub-folder structure is a fresh download of the libraries:
mylibrary/main.cpp occt-7_8_0/ freetype-2.10.4/ tcl8.5.0/ tk8.5.0/ I don't want to use VTK and my main.cpp might look like:
#include #include
void makeBox(){ gp_Pnt gp1(0,0,0); gp_Pnt gp2(1,1,1); TopoDS_Solid box = BRepPrimAPI_MakeBox(gp1, gp2).Solid(); } And the CMakesList.txt of mylibrary/ is
message("=== Occt wrapper as a lib ===") add_library(mylibrary_lib SHARED) if (CMAKE_COMPILER_IS_GNUCXX) add_compile_options(-Wa,-mbig-obj) endif() if (MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") endif() # find_package() uses Config.cmake-file in _DIR path find_package(OpenCASCADE REQUIRED) target_include_directories(mylibrary_lib PRIVATE "${OpenCASCADE_INCLUDE_DIR}") # OCC is needed if(NOT OpenCASCADE_FOUND) message(FATAL_ERROR "Cannot build the executable without OpenCASCADE. Please set the variable OpenCASCADE_DIR.") else() message(" found OpenCASCADE " ${OpenCASCADE_VERSION}) # include target_include_directories(mylibrary_lib PUBLIC ${OpenCASCADE_INCLUDE_DIR}) message(" found OpenCASCADE_INCLUDE_DIR: ${OpenCASCADE_INCLUDE_DIR}" ) # link target_link_libraries(mylibrary_lib PUBLIC ${OpenCASCADE_LIBRARIES}) # This should be private! message(" found OpenCASCADE_LIBRARIES: ${OpenCASCADE_LIBRARIES}" ) endif() target_sources(mylibrary_lib PUBLIC "./main.cpp")
Источник: https://stackoverflow.com/questions/781 ... sing-cmake
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение