Skip to content
Open

Qt5 #136

Show file tree
Hide file tree
Changes from all 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
46 changes: 37 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PROJECT( tinia )
CMAKE_MINIMUM_REQUIRED( VERSION 2.6)
SET( version_number "0.3.0" )
CMAKE_MINIMUM_REQUIRED( VERSION 2.8.12)
SET( version_number "0.4.0" )
SET(TINIA_VERSION ${version_number})

IF(NOT CMAKE_BUILD_TYPE)
Expand All @@ -13,6 +13,10 @@ SET(CMAKE_DEBUG_POSTFIX "d")

ENDIF(NOT CMAKE_BUILD_TYPE)

cmake_policy(SET CMP0053 OLD)
cmake_policy(SET CMP0043 OLD)
cmake_policy(SET CMP0020 OLD)

# Set shared for linux:
IF(NOT WIN32)
IF(NOT DEFINED ${BUILD_SHARED_LIBS})
Expand Down Expand Up @@ -76,10 +80,11 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
ENDIF( Tinia_IPC_LOG_TRACE )
ENDIF()

IF(MSVC10)
IF(WIN32)
#Enable multiprocessor compilation for speed
#SET(CMAKE_CXX_FLAGS " /MP ${CMAKE_CXX_FLAGS}" CACHE STRING " " FORCE)
#CAREFUL, this will append the above string for each time CMAKE is run!
#Requires CMAKE 2.8.12 or later
ADD_COMPILE_OPTIONS( /MP )

ENDIF()


Expand Down Expand Up @@ -107,21 +112,44 @@ set(Boost_USE_STATIC_RUNTIME OFF)
FIND_PACKAGE( Boost REQUIRED COMPONENTS unit_test_framework prg_exec_monitor thread date_time system )
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} ${Boost_LIBRARIES})

##### QT #####
##### QT #####
IF(Tinia_DESKTOP)
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtOpenGL QtXML QtScript QtNetwork REQUIRED)
INCLUDE(${QT_USE_FILE})
SET( CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH};${Qt5_ROOT}" )
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_AUTOMOC ON)
FIND_PACKAGE(Qt5Core)
FIND_PACKAGE(Qt5Widgets)
FIND_PACKAGE(Qt5OpenGL)
FIND_PACKAGE(Qt5Xml )
FIND_PACKAGE(Qt5Script)
FIND_PACKAGE(Qt5Network)
FIND_PACKAGE(Qt5Gui)
SET(QT_USE_QTOPENGL TRUE)
SET(QT_USE_QTXML TRUE)
SET(QT_USE_QTNETWORK TRUE)
SET(QT_USE_QTSCRIPT TRUE)
QT4_WRAP_CPP(qtcontroller_HEADERS_MOC ${qtcontroller_SOURCES_TO_BE_MOCED} ${qtcontroller_SOURCES})
QT4_WRAP_UI(qtcontroller_FORMS_HEADERS ${qtcontroller_FORMS})
QT5_WRAP_CPP(qtcontroller_HEADERS_MOC ${qtcontroller_SOURCES_TO_BE_MOCED} ${qtcontroller_SOURCES})
QT5_WRAP_UI(qtcontroller_FORMS_HEADERS ${qtcontroller_FORMS})
ADD_DEFINITIONS(${QT_DEFINITIONS})
ADD_DEFINITIONS(-DQT_SHARED)
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} ${LIBXML2_LIBRARIES} ${QT_LIBRARIES})
ENDIF()

#IF(Tinia_DESKTOP)
# FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtOpenGL QtXML QtScript QtNetwork REQUIRED)
# INCLUDE(${QT_USE_FILE})
# SET(QT_USE_QTOPENGL TRUE)
# SET(QT_USE_QTXML TRUE)
# SET(QT_USE_QTNETWORK TRUE)
# SET(QT_USE_QTSCRIPT TRUE)
# QT4_WRAP_CPP(qtcontroller_HEADERS_MOC ${qtcontroller_SOURCES_TO_BE_MOCED} ${qtcontroller_SOURCES})
# QT4_WRAP_UI(qtcontroller_FORMS_HEADERS ${qtcontroller_FORMS})
# ADD_DEFINITIONS(${QT_DEFINITIONS})
# ADD_DEFINITIONS(-DQT_SHARED)
# SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} ${LIBXML2_LIBRARIES} ${QT_LIBRARIES})
#ENDIF()


##### OPENGL #####
FIND_PACKAGE( OpenGL REQUIRED )
Expand Down
6 changes: 3 additions & 3 deletions examples/fpsviewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FILE( GLOB fpsviewer_HEADERS "*.hpp" )
FILE( GLOB fpsviewer_JS_SOURCES "*.js" )
FILE(GLOB fpsviewer_RESOURCES "*.qrc" )
QT4_ADD_RESOURCES( fpsviewer_QRC_SOURCES ${fpsviewer_RESOURCES} )
QT5_ADD_RESOURCES( fpsviewer_QRC_SOURCES ${fpsviewer_RESOURCES} )

IF(Tinia_DESKTOP)

Expand All @@ -17,16 +17,16 @@ ADD_EXECUTABLE(fpsviewer_desktop
tinia_qtcontroller
tinia_renderlist
tinia_renderlistgl
${QT_LIBRARIES}
${QT_QTOPENGL_LIBRARIES}
${OPENGL_LIBRARIES}
${GLEW_LIBRARY}
tinia_jobcontroller
${Boost_LIBRARIES}
)
QT5_USE_MODULES( fpsviewer_desktop OpenGL )
ENDIF()



IF(Tinia_SERVER)
ADD_EXECUTABLE(fpsviewer_web
${tutorial_HEADERS}
Expand Down
4 changes: 2 additions & 2 deletions examples/fpsviewer/fpsviewer_desktop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ int main(int argc, char** argv) {
//Q_INIT_RESOURCE( tutorial5 );
QFile viewerSourceLoc( ":tutorial5/javascript/FPSViewer.js" );
if( !viewerSourceLoc.open( (QIODevice::ReadOnly | QIODevice::Text) ) ) {
std::string err = std::string(viewerSourceLoc.errorString().toAscii() );
std::string err = std::string(viewerSourceLoc.errorString().toLatin1() );
throw std::runtime_error( "Could not open file in QRC, aborting." + err);
}

std::string viewerSource ( QString(viewerSourceLoc.readAll()).toAscii() );
std::string viewerSource ( QString(viewerSourceLoc.readAll()).toLatin1() );
controller.addScript( viewerSource );

/** [jobtocontroller] */
Expand Down
4 changes: 2 additions & 2 deletions js/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FILE(GLOB javascript_RESOURCES "*.qrc")
FILE(GLOB_RECURSE javascript_SOURCES "." "*.js" "*.html" "*.css")
QT4_ADD_RESOURCES( javascript_QRC_SOURCES ${javascript_RESOURCES} )
QT5_ADD_RESOURCES( javascript_QRC_SOURCES ${javascript_RESOURCES} )

add_library( tinia_javascript
${javascript_QRC_SOURCES}
${javascript_SOURCES}
)
target_link_libraries ( tinia_javascript
${QT_LIBRARIES}
)

QT5_USE_MODULES( tinia_javascript Core)

install( TARGETS
tinia_javascript
Expand Down
15 changes: 7 additions & 8 deletions src/qtcontroller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ IF(NOT LIBXML2_FOUND)
LIST(REMOVE_ITEM qtcontroller_HEADERS ${serverToRemove})

ENDIF()
QT4_ADD_RESOURCES( qtcontroller_QRC_SOURCES ${qtcontroller_RESOURCES} )
QT4_WRAP_CPP(qtcontroller_HEADERS_MOC ${qtcontroller_SOURCES_TO_BE_MOCED})# ${qtcontroller_SOURCES})
QT4_WRAP_UI(qtcontroller_FORMS_HEADERS ${qtcontroller_FORMS})
QT5_ADD_RESOURCES( qtcontroller_QRC_SOURCES ${qtcontroller_RESOURCES} )
QT5_WRAP_CPP(qtcontroller_HEADERS_MOC ${qtcontroller_SOURCES_TO_BE_MOCED})# ${qtcontroller_SOURCES})
QT5_WRAP_UI(qtcontroller_FORMS_HEADERS ${qtcontroller_FORMS})

add_library( tinia_qtcontroller
${qtcontroller_QRC_SOURCES}
Expand All @@ -39,29 +39,28 @@ target_link_libraries ( tinia_qtcontroller
tinia_javascript
${LIBXML2_LIBRARIES}
tinia_modelxml
${QT_LIBRARIES}
${QT_QTOPENGL_LIBRARIES}
tinia_jobcontroller
${Boost_LIBRARIES}
${OPENGL_LIBRARIES}
${GLEW_LIBRARY}
${Freeglut_LIBRARY}
)
ELSe()
ELSE()
target_link_libraries ( tinia_qtcontroller
tinia_renderlist
tinia_renderlistgl
tinia_model
tinia_javascript
${QT_LIBRARIES}
${QT_QTOPENGL_LIBRARIES}
tinia_jobcontroller
${Boost_LIBRARIES}
${OPENGL_LIBRARIES}
${GLEW_LIBRARY}
${Freeglut_LIBRARY}
)
ENDIF()

QT5_USE_MODULES( tinia_qtcontroller OpenGL Script Network Xml)

# The reason for the development name to be <component>_dev is
# that using <component>-dev does not work with NSIS Windows installer.
# Remember to also update the list of components in the
Expand Down
10 changes: 4 additions & 6 deletions tutorials/tutorial5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ FILE( GLOB tutorial_DOC "*.md" )
FILE( GLOB tutorial_JS_SOURCES "*.js" )

FILE(GLOB tutorial_RESOURCES "*.qrc" )
QT4_ADD_RESOURCES( tutorial_QRC_SOURCES ${tutorial_RESOURCES} )
QT5_ADD_RESOURCES( tutorial_QRC_SOURCES ${tutorial_RESOURCES} )


IF(Tinia_DESKTOP)
Expand All @@ -22,14 +22,14 @@ ADD_EXECUTABLE(tutorial5_desktop
tinia_qtcontroller
tinia_renderlist
tinia_renderlistgl
${QT_LIBRARIES}
${QT_QTOPENGL_LIBRARIES}

${OPENGL_LIBRARIES}
${GLEW_LIBRARY}
${Freeglut_LIBRARY}
tinia_jobcontroller
${Boost_LIBRARIES}
)
QT5_USE_MODULES( tutorial5_desktop OpenGL )
ENDIF()


Expand All @@ -44,8 +44,6 @@ IF(Tinia_SERVER)
TARGET_LINK_LIBRARIES(tutorial5_web
${TINIA_LIBRARIES}
${GLEW_LIBRARY}
${QT_LIBRARIES}
${QT_QTOPENGL_LIBRARIES}
${OPENGL_LIBRARIES}
${Freeglut_LIBRARY}
${Boost_LIBRARIES}
Expand All @@ -58,7 +56,7 @@ IF(Tinia_SERVER)
tinia_trell
)


QT5_USE_MODULES( tutorial5_web OpenGL )
INSTALL(TARGETS
tutorial5_web
EXPORT TiniaTargets
Expand Down
4 changes: 2 additions & 2 deletions tutorials/tutorial5/tutorial5_desktop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ int main(int argc, char** argv) {
//Q_INIT_RESOURCE( tutorial5 );
QFile viewerSourceLoc( ":/tutorial5.js" );
if( !viewerSourceLoc.open( (QIODevice::ReadOnly | QIODevice::Text) ) ) {
std::string err = std::string(viewerSourceLoc.errorString().toAscii() );
std::string err = std::string(viewerSourceLoc.errorString().toLatin1() );
throw std::runtime_error( "Could not open file in QRC, aborting." + err);
}

std::string viewerSource ( QString(viewerSourceLoc.readAll()).toAscii() );
std::string viewerSource ( QString(viewerSourceLoc.readAll()).toLatin1() );
controller.addScript( viewerSource );

/** [jobtocontroller] */
Expand Down