Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake build updated to work with Windows VS2019 (vc-142) #79

Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 104 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ if(POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif()

project(libQGLViewer LANGUAGES CXX VERSION 2.9.1)
cmake_minimum_required(VERSION 3.16)
project(libQGLViewer LANGUAGES CXX VERSION 2.9.1)

# Qt6 minimum compiler version
set(CMAKE_CXX_STANDARD 17)
Expand All @@ -19,48 +19,116 @@ set(CMAKE_AUTOUIC ON)
# This will find the Qt files.
find_package(Qt6 COMPONENTS Core Widgets Xml OpenGL OpenGLWidgets)
if (Qt6_FOUND)
message("Building with Qt6")
message("Qt6 found!")
set(QtLibs Qt::Core Qt::Widgets Qt::Xml Qt::OpenGL Qt::OpenGLWidgets)
else()
find_package(Qt5 5.15 REQUIRED COMPONENTS Core Widgets Xml OpenGL)
message("Building with Qt5")
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Xml OpenGL)
if(Qt5_FOUND)
message("Qt5 found! Preferring Qt5 for now.")
set(QtLibs Qt::Core Qt::Widgets Qt::Xml Qt::OpenGL)
endif()
endif()


find_package(OpenGL REQUIRED)

# QGLViewer target.
set(QGLViewer_SRC
"${PROJECT_SOURCE_DIR}/QGLViewer/VRender/BackFaceCullingOptimizer.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/VRender/BSPSortMethod.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/VRender/EPSExporter.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/VRender/Exporter.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/VRender/FIGExporter.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/VRender/gpc.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/VRender/NVector3.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/VRender/ParserGL.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/VRender/Primitive.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/VRender/PrimitivePositioning.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/VRender/TopologicalSortMethod.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/VRender/Vector2.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/VRender/Vector3.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/VRender/VisibilityOptimizer.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/VRender/VRender.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/camera.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/constraint.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/frame.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/keyFrameInterpolator.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/manipulatedCameraFrame.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/manipulatedFrame.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/mouseGrabber.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/qglviewer.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/quaternion.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/saveSnapshot.cpp"
"${PROJECT_SOURCE_DIR}/QGLViewer/vec.cpp")
add_library(QGLViewer SHARED ${QGLViewer_SRC})
target_include_directories(QGLViewer INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(QGLViewer PRIVATE ${QtLibs} OpenGL::GL OpenGL::GLU)
include_directories(
"${PROJECT_SOURCE_DIR}/QGLViewer/"
)

set(MOC_HEADER_FILES
QGLViewer/camera.h
QGLViewer/frame.h
QGLViewer/keyFrameInterpolator.h
QGLViewer/manipulatedCameraFrame.h
QGLViewer/manipulatedFrame.h
QGLViewer/qglviewer.h
)
# These header files don't need to be processed by the moc.
set(HEADER_FILES
QGLViewer/VRender/AxisAlignedBox.h
QGLViewer/VRender/Exporter.h
QGLViewer/VRender/NVector3.h
QGLViewer/VRender/Optimizer.h
QGLViewer/VRender/ParserGL.h
QGLViewer/VRender/Primitive.h
QGLViewer/VRender/PrimitivePositioning.h
QGLViewer/VRender/SortMethod.h
QGLViewer/VRender/Types.h
QGLViewer/VRender/VRender.h
QGLViewer/VRender/Vector2.h
QGLViewer/VRender/Vector3.h
QGLViewer/VRender/gpc.h
QGLViewer/config.h
QGLViewer/constraint.h
QGLViewer/domUtils.h
QGLViewer/mouseGrabber.h
QGLViewer/quaternion.h
QGLViewer/vec.h
)
set(SOURCE_FILES
QGLViewer/VRender/BSPSortMethod.cpp
QGLViewer/VRender/BackFaceCullingOptimizer.cpp
QGLViewer/VRender/EPSExporter.cpp
QGLViewer/VRender/Exporter.cpp
QGLViewer/VRender/FIGExporter.cpp
QGLViewer/VRender/NVector3.cpp
QGLViewer/VRender/ParserGL.cpp
QGLViewer/VRender/Primitive.cpp
QGLViewer/VRender/PrimitivePositioning.cpp
QGLViewer/VRender/TopologicalSortMethod.cpp
QGLViewer/VRender/VRender.cpp
QGLViewer/VRender/Vector2.cpp
QGLViewer/VRender/Vector3.cpp
QGLViewer/VRender/VisibilityOptimizer.cpp
QGLViewer/VRender/gpc.cpp
QGLViewer/camera.cpp
QGLViewer/constraint.cpp
QGLViewer/frame.cpp
QGLViewer/keyFrameInterpolator.cpp
QGLViewer/manipulatedCameraFrame.cpp
QGLViewer/manipulatedFrame.cpp
QGLViewer/mouseGrabber.cpp
QGLViewer/qglviewer.cpp
QGLViewer/quaternion.cpp
QGLViewer/saveSnapshot.cpp
QGLViewer/vec.cpp
)
set(UI_FILES
QGLViewer/ImageInterface.ui
QGLViewer/VRenderInterface.ui
)

add_library(QGLViewer SHARED ${HEADER_FILES} ${MOC_FILES} ${FORM_FILES} ${SOURCE_FILES})

# WIN32 and UNIX/LINUX use different names for the OpenGL lib
if (WIN32)
set(OPENGL_LIB OpenGL32)
else()
set(OPENGL_LIB OpenGL)
endif()

target_link_libraries(QGLViewer
PUBLIC
${QtLibs}
${OPENGL_LIB}
OpenGL::GLU
)
dennis2society marked this conversation as resolved.
Show resolved Hide resolved

if(WIN32)
# ignore minwindef.h to use std::min/max
add_compile_definitions(NOMINMAX)
target_compile_options(QGLViewer PRIVATE "-DCREATE_QGLVIEWER_DLL")
# remove warnings about deprecation (CRT,etc)
target_compile_options(QGLViewer PRIVATE "/wd4996")
endif()

add_custom_command(
TARGET QGLViewer
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"$<TARGET_FILE:QGLViewer>"
"${CMAKE_BINARY_DIR}"
)

# Example: animation.
set(animation_SRC
Expand Down
1 change: 1 addition & 0 deletions QGLViewer/VRender/Primitive.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace vrender
{
class Feedback3DColor ;
class Primitive ;
std::ostream& operator<<(std::ostream&, const Feedback3DColor&);

#define EPS_SMOOTH_LINE_FACTOR 0.06 /* Lower for better smooth lines. */

Expand Down
2 changes: 2 additions & 0 deletions QGLViewer/VRender/Vector3.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
namespace vrender
{
class NVector3;
class Vector3;
std::ostream& operator<< (std::ostream&, const Vector3&);

class Vector3
{
Expand Down