From 45afce48f748ccfdd80088b98befc88213d91b72 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 11:29:13 -0700 Subject: [PATCH 01/43] remember old session UUID in AvatarHashMap to work around ghosting --- interface/src/Application.cpp | 3 +- libraries/avatars/src/AvatarData.h | 2 +- libraries/avatars/src/AvatarHashMap.cpp | 30 ++++++++++++++------ libraries/avatars/src/AvatarHashMap.h | 8 ++++-- libraries/networking/src/LimitedNodeList.cpp | 2 +- libraries/networking/src/LimitedNodeList.h | 2 +- 6 files changed, 31 insertions(+), 16 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7eb087c531..6f7212e68f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -261,8 +261,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), SLOT(nodeKilled(SharedNodePointer))); connect(nodeList, SIGNAL(nodeAdded(SharedNodePointer)), &_voxels, SLOT(nodeAdded(SharedNodePointer))); connect(nodeList, SIGNAL(nodeKilled(SharedNodePointer)), &_voxels, SLOT(nodeKilled(SharedNodePointer))); - connect(nodeList, &NodeList::uuidChanged, this, &Application::updateWindowTitle); - connect(nodeList, SIGNAL(uuidChanged(const QUuid&)), _myAvatar, SLOT(setSessionUUID(const QUuid&))); + connect(nodeList, &NodeList::uuidChanged, _myAvatar, &MyAvatar::setSessionUUID); connect(nodeList, &NodeList::limitOfSilentDomainCheckInsReached, nodeList, &NodeList::reset); // connect to appropriate slots on AccountManager diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index 2971598c1d..a4bb0d48bb 100755 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -290,7 +290,7 @@ public slots: void sendBillboardPacket(); void setBillboardFromNetworkReply(); void setJointMappingsFromNetworkReply(); - void setSessionUUID(const QUuid& id) { _sessionUUID = id; } + void setSessionUUID(const QUuid& sessionUUID) { _sessionUUID = sessionUUID; } bool hasReferential(); protected: diff --git a/libraries/avatars/src/AvatarHashMap.cpp b/libraries/avatars/src/AvatarHashMap.cpp index 8e3797cbc0..202121bad3 100644 --- a/libraries/avatars/src/AvatarHashMap.cpp +++ b/libraries/avatars/src/AvatarHashMap.cpp @@ -9,19 +9,21 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include #include #include "AvatarHashMap.h" AvatarHashMap::AvatarHashMap() : - _avatarHash() + _avatarHash(), + _lastOwnerSessionUUID() { - + connect(NodeList::getInstance(), &NodeList::uuidChanged, this, &AvatarHashMap::sessionUUIDChanged); } -void AvatarHashMap::insert(const QUuid& id, AvatarSharedPointer avatar) { - _avatarHash.insert(id, avatar); - avatar->setSessionUUID(id); +void AvatarHashMap::insert(const QUuid& sessionUUID, AvatarSharedPointer avatar) { + _avatarHash.insert(sessionUUID, avatar); + avatar->setSessionUUID(sessionUUID); } AvatarHash::iterator AvatarHashMap::erase(const AvatarHash::iterator& iterator) { @@ -110,10 +112,16 @@ void AvatarHashMap::processAvatarDataPacket(const QByteArray &datagram, const QW QUuid sessionUUID = QUuid::fromRfc4122(datagram.mid(bytesRead, NUM_BYTES_RFC4122_UUID)); bytesRead += NUM_BYTES_RFC4122_UUID; - AvatarSharedPointer matchingAvatarData = matchingOrNewAvatar(sessionUUID, mixerWeakPointer); - - // have the matching (or new) avatar parse the data from the packet - bytesRead += matchingAvatarData->parseDataAtOffset(datagram, bytesRead); + if (sessionUUID != _lastOwnerSessionUUID) { + AvatarSharedPointer matchingAvatarData = matchingOrNewAvatar(sessionUUID, mixerWeakPointer); + + // have the matching (or new) avatar parse the data from the packet + bytesRead += matchingAvatarData->parseDataAtOffset(datagram, bytesRead); + } else { + // create a dummy AvatarData class to throw this data on the ground + AvatarData dummyData; + bytesRead += dummyData.parseDataAtOffset(datagram, bytesRead); + } } } @@ -177,3 +185,7 @@ void AvatarHashMap::processKillAvatar(const QByteArray& datagram) { erase(matchedAvatar); } } + +void AvatarHashMap::sessionUUIDChanged(const QUuid& sessionUUID, const QUuid& oldUUID) { + _lastOwnerSessionUUID = oldUUID; +} \ No newline at end of file diff --git a/libraries/avatars/src/AvatarHashMap.h b/libraries/avatars/src/AvatarHashMap.h index 542a2d62ab..fe9ab3d634 100644 --- a/libraries/avatars/src/AvatarHashMap.h +++ b/libraries/avatars/src/AvatarHashMap.h @@ -31,12 +31,15 @@ public: const AvatarHash& getAvatarHash() { return _avatarHash; } int size() const { return _avatarHash.size(); } - virtual void insert(const QUuid& id, AvatarSharedPointer avatar); + virtual void insert(const QUuid& sessionUUID, AvatarSharedPointer avatar); public slots: void processAvatarMixerDatagram(const QByteArray& datagram, const QWeakPointer& mixerWeakPointer); bool containsAvatarWithDisplayName(const QString& displayName); - + +private slots: + void sessionUUIDChanged(const QUuid& sessionUUID, const QUuid& oldUUID); + protected: virtual AvatarHash::iterator erase(const AvatarHash::iterator& iterator); @@ -51,6 +54,7 @@ protected: void processKillAvatar(const QByteArray& datagram); AvatarHash _avatarHash; + QUuid _lastOwnerSessionUUID; }; #endif // hifi_AvatarHashMap_h diff --git a/libraries/networking/src/LimitedNodeList.cpp b/libraries/networking/src/LimitedNodeList.cpp index c0d7941edf..13dc558687 100644 --- a/libraries/networking/src/LimitedNodeList.cpp +++ b/libraries/networking/src/LimitedNodeList.cpp @@ -95,7 +95,7 @@ void LimitedNodeList::setSessionUUID(const QUuid& sessionUUID) { if (sessionUUID != oldUUID) { qDebug() << "NodeList UUID changed from" << uuidStringWithoutCurlyBraces(oldUUID) << "to" << uuidStringWithoutCurlyBraces(_sessionUUID); - emit uuidChanged(sessionUUID); + emit uuidChanged(sessionUUID, oldUUID); } } diff --git a/libraries/networking/src/LimitedNodeList.h b/libraries/networking/src/LimitedNodeList.h index a4bc8022bf..3e62d4aaab 100644 --- a/libraries/networking/src/LimitedNodeList.h +++ b/libraries/networking/src/LimitedNodeList.h @@ -107,7 +107,7 @@ public slots: void killNodeWithUUID(const QUuid& nodeUUID); signals: - void uuidChanged(const QUuid& ownerUUID); + void uuidChanged(const QUuid& ownerUUID, const QUuid& oldUUID); void nodeAdded(SharedNodePointer); void nodeKilled(SharedNodePointer); protected: From 9a50532b1f1fa55b4f0b668abfc5947b88f8f87b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 14:22:42 -0700 Subject: [PATCH 02/43] bubble up sub dependencies to link_hifi_library --- cmake/macros/LinkHifiLibrary.cmake | 2 +- interface/CMakeLists.txt | 6 ------ libraries/octree/CMakeLists.txt | 10 ++++++++-- libraries/shared/CMakeLists.txt | 5 ++++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/cmake/macros/LinkHifiLibrary.cmake b/cmake/macros/LinkHifiLibrary.cmake index 6300e50c34..577f0c9f37 100644 --- a/cmake/macros/LinkHifiLibrary.cmake +++ b/cmake/macros/LinkHifiLibrary.cmake @@ -16,7 +16,7 @@ macro(LINK_HIFI_LIBRARY LIBRARY TARGET ROOT_DIR) include_directories("${ROOT_DIR}/libraries/${LIBRARY}/src") add_dependencies(${TARGET} ${LIBRARY}) - target_link_libraries(${TARGET} ${LIBRARY}) + target_link_libraries(${TARGET} ${LIBRARY} ${REQUIRED_DEPENDENCY_LIBRARIES}) if (APPLE) # currently the "shared" library requires CoreServices diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 7336b55852..5c1bec0321 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -126,7 +126,6 @@ find_package(LeapMotion) find_package(ZLIB) find_package(Qxmpp) find_package(RtMidi) -find_package(OpenSSL REQUIRED) # perform standard include and linking for found externals foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) @@ -180,14 +179,9 @@ endif () # include headers for interface and InterfaceConfig. include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes") -# include external library headers -# use system flag so warnings are supressed -include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") - target_link_libraries( ${TARGET_NAME} "${ZLIB_LIBRARIES}" - ${OPENSSL_LIBRARIES} Qt5::Core Qt5::Gui Qt5::Multimedia Qt5::Network Qt5::OpenGL Qt5::Script Qt5::Svg Qt5::WebKit Qt5::WebKitWidgets Qt5::Xml Qt5::UiTools ) diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index 031f7ef69a..398bf80157 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -20,9 +20,15 @@ link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") # link ZLIB find_package(ZLIB) +find_package(OpenSSL REQUIRED) -include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets) +include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") + +# bubble up the libraries we are dependent on +set(REQUIRED_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} + "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}" Qt5::Widgets PARENT_SCOPE) + +target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index f099f424e9..c0d59c8b75 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -30,4 +30,7 @@ endif (UNIX AND NOT APPLE) # directory when Qt5 (5.2.1) is compiled from source and is not in a standard place. include_directories(SYSTEM "${Qt5Script_INCLUDE_DIRS}") -target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets) +# bubble up the libraries we are dependent on and link them to ourselves +set(REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) +set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) +target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) \ No newline at end of file From 33e58268423babe05d0f36c21b33fc9509a999b5 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 14:57:09 -0700 Subject: [PATCH 03/43] remove animation server, bubble up qt modules --- CMakeLists.txt | 5 - animation-server/CMakeLists.txt | 39 -- animation-server/src/AnimationServer.cpp | 852 ----------------------- animation-server/src/AnimationServer.h | 27 - animation-server/src/main.cpp | 17 - assignment-client/CMakeLists.txt | 4 - cmake/macros/LinkHifiLibrary.cmake | 8 +- libraries/networking/CMakeLists.txt | 7 +- libraries/octree/CMakeLists.txt | 4 +- libraries/shared/CMakeLists.txt | 20 +- 10 files changed, 18 insertions(+), 965 deletions(-) delete mode 100644 animation-server/CMakeLists.txt delete mode 100644 animation-server/src/AnimationServer.cpp delete mode 100644 animation-server/src/AnimationServer.h delete mode 100644 animation-server/src/main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dbc89b75f..578c36841d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,11 +44,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) -# targets not supported on windows -if (NOT WIN32) - add_subdirectory(animation-server) -endif () - # targets on all platforms add_subdirectory(assignment-client) add_subdirectory(domain-server) diff --git a/animation-server/CMakeLists.txt b/animation-server/CMakeLists.txt deleted file mode 100644 index 116ee0e942..0000000000 --- a/animation-server/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -if (WIN32) - cmake_policy (SET CMP0020 NEW) -endif (WIN32) - -set(TARGET_NAME animation-server) - -set(ROOT_DIR ..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") - -find_package(Qt5 COMPONENTS Script) -include_directories(SYSTEM "${Qt5Script_INCLUDE_DIRS}") - -# set up the external glm library -include("${MACRO_DIR}/IncludeGLM.cmake") -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -include("${MACRO_DIR}/SetupHifiProject.cmake") -setup_hifi_project(${TARGET_NAME} TRUE) - -# link in the shared library -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") - -# link in the hifi octree library -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") - -# link in the hifi voxels library -link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") - -# link the hifi networking library -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () diff --git a/animation-server/src/AnimationServer.cpp b/animation-server/src/AnimationServer.cpp deleted file mode 100644 index 32a95b48ea..0000000000 --- a/animation-server/src/AnimationServer.cpp +++ /dev/null @@ -1,852 +0,0 @@ -// -// AnimationServer.cpp -// animation-server/src -// -// Created by Stephen Birarda on 12/5/2013. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "AnimationServer.h" - -bool shouldShowPacketsPerSecond = false; // do we want to debug packets per second -bool includeBillboard = true; -bool includeBorderTracer = true; -bool includeMovingBug = true; -bool includeBlinkingVoxel = false; -bool includeDanceFloor = true; -bool buildStreet = false; -bool nonThreadedPacketSender = false; -int packetsPerSecond = PacketSender::DEFAULT_PACKETS_PER_SECOND; -bool waitForVoxelServer = true; - - -const int ANIMATION_LISTEN_PORT = 40107; -int ANIMATE_FPS = 60; -double ANIMATE_FPS_IN_MILLISECONDS = 1000.0/ANIMATE_FPS; // determines FPS from our desired FPS -quint64 ANIMATE_VOXELS_INTERVAL_USECS = (ANIMATE_FPS_IN_MILLISECONDS * 1000); // converts from milliseconds to usecs - - -int PROCESSING_FPS = 60; -double PROCESSING_FPS_IN_MILLISECONDS = 1000.0/PROCESSING_FPS; // determines FPS from our desired FPS -int FUDGE_USECS = 650; // a little bit of fudge to actually do some processing -quint64 PROCESSING_INTERVAL_USECS = (PROCESSING_FPS_IN_MILLISECONDS * 1000) - FUDGE_USECS; // converts from milliseconds to usecs - -bool wantLocalDomain = false; - -unsigned long packetsSent = 0; -unsigned long bytesSent = 0; - -JurisdictionListener* jurisdictionListener = NULL; -VoxelEditPacketSender* voxelEditPacketSender = NULL; -pthread_t animateVoxelThread; - -glm::vec3 rotatePoint(glm::vec3 point, float angle) { - // First, create the quaternion based on this angle of rotation - glm::quat q(glm::vec3(0, -angle, 0)); - - // Next, create a rotation matrix from that quaternion - glm::mat4 rotation = glm::mat4_cast(q); - - // Transform the original vectors by the rotation matrix to get the new vectors - glm::vec4 quatPoint(point.x, point.y, point.z, 0); - glm::vec4 newPoint = quatPoint * rotation; - - return glm::vec3(newPoint.x, newPoint.y, newPoint.z); -} - - -const float BUG_VOXEL_SIZE = 0.0625f / TREE_SCALE; -glm::vec3 bugPosition = glm::vec3(BUG_VOXEL_SIZE * 20.0, BUG_VOXEL_SIZE * 30.0, BUG_VOXEL_SIZE * 20.0); -glm::vec3 bugDirection = glm::vec3(0, 0, 1); -const int VOXELS_PER_BUG = 18; -glm::vec3 bugPathCenter = glm::vec3(0.25f,0.15f,0.25f); // glm::vec3(BUG_VOXEL_SIZE * 150.0, BUG_VOXEL_SIZE * 30.0, BUG_VOXEL_SIZE * 150.0); -float bugPathRadius = 0.2f; //BUG_VOXEL_SIZE * 140.0; -float bugPathTheta = 0.0f * RADIANS_PER_DEGREE; -float bugRotation = 0.0f * RADIANS_PER_DEGREE; -float bugAngleDelta = 0.2f * RADIANS_PER_DEGREE; -bool moveBugInLine = false; - -class BugPart { -public: - glm::vec3 partLocation; - unsigned char partColor[3]; - - BugPart(const glm::vec3& location, unsigned char red, unsigned char green, unsigned char blue ) { - partLocation = location; - partColor[0] = red; - partColor[1] = green; - partColor[2] = blue; - } -}; - -const BugPart bugParts[VOXELS_PER_BUG] = { - - // tail - BugPart(glm::vec3( 0, 0, -3), 51, 51, 153) , - BugPart(glm::vec3( 0, 0, -2), 51, 51, 153) , - BugPart(glm::vec3( 0, 0, -1), 51, 51, 153) , - - // body - BugPart(glm::vec3( 0, 0, 0), 255, 200, 0) , - BugPart(glm::vec3( 0, 0, 1), 255, 200, 0) , - - // head - BugPart(glm::vec3( 0, 0, 2), 200, 0, 0) , - - // eyes - BugPart(glm::vec3( 1, 0, 3), 64, 64, 64) , - BugPart(glm::vec3(-1, 0, 3), 64, 64, 64) , - - // wings - BugPart(glm::vec3( 3, 1, 1), 0, 153, 0) , - BugPart(glm::vec3( 2, 1, 1), 0, 153, 0) , - BugPart(glm::vec3( 1, 0, 1), 0, 153, 0) , - BugPart(glm::vec3(-1, 0, 1), 0, 153, 0) , - BugPart(glm::vec3(-2, 1, 1), 0, 153, 0) , - BugPart(glm::vec3(-3, 1, 1), 0, 153, 0) , - - - BugPart(glm::vec3( 2, -1, 0), 153, 200, 0) , - BugPart(glm::vec3( 1, -1, 0), 153, 200, 0) , - BugPart(glm::vec3(-1, -1, 0), 153, 200, 0) , - BugPart(glm::vec3(-2, -1, 0), 153, 200, 0) , -}; - -static void renderMovingBug() { - VoxelDetail details[VOXELS_PER_BUG]; - - // Generate voxels for where bug used to be - for (int i = 0; i < VOXELS_PER_BUG; i++) { - details[i].s = BUG_VOXEL_SIZE; - - glm::vec3 partAt = bugParts[i].partLocation * BUG_VOXEL_SIZE * (bugDirection.x < 0 ? -1.0f : 1.0f); - glm::vec3 rotatedPartAt = rotatePoint(partAt, bugRotation); - glm::vec3 offsetPartAt = rotatedPartAt + bugPosition; - - details[i].x = offsetPartAt.x; - details[i].y = offsetPartAt.y; - details[i].z = offsetPartAt.z; - - details[i].red = bugParts[i].partColor[0]; - details[i].green = bugParts[i].partColor[1]; - details[i].blue = bugParts[i].partColor[2]; - } - - // send the "erase message" first... - PacketType message = PacketTypeVoxelErase; - ::voxelEditPacketSender->queueVoxelEditMessages(message, VOXELS_PER_BUG, (VoxelDetail*)&details); - - // Move the bug... - if (moveBugInLine) { - bugPosition.x += (bugDirection.x * BUG_VOXEL_SIZE); - bugPosition.y += (bugDirection.y * BUG_VOXEL_SIZE); - bugPosition.z += (bugDirection.z * BUG_VOXEL_SIZE); - - // Check boundaries - if (bugPosition.z > 1.0f) { - bugDirection.z = -1.f; - } - if (bugPosition.z < BUG_VOXEL_SIZE) { - bugDirection.z = 1.f; - } - } else { - - //qDebug("bugPathCenter=(%f,%f,%f)", bugPathCenter.x, bugPathCenter.y, bugPathCenter.z); - - bugPathTheta += bugAngleDelta; // move slightly - bugRotation -= bugAngleDelta; // rotate slightly - - // If we loop past end of circle, just reset back into normal range - if (bugPathTheta > TWO_PI) { - bugPathTheta = 0.f; - bugRotation = 0.f; - } - - float x = bugPathCenter.x + bugPathRadius * cos(bugPathTheta); - float z = bugPathCenter.z + bugPathRadius * sin(bugPathTheta); - float y = bugPathCenter.y; - - bugPosition = glm::vec3(x, y, z); - //qDebug("bugPathTheta=%f", bugPathTheta); - //qDebug("bugRotation=%f", bugRotation); - } - - //qDebug("bugPosition=(%f,%f,%f)", bugPosition.x, bugPosition.y, bugPosition.z); - //qDebug("bugDirection=(%f,%f,%f)", bugDirection.x, bugDirection.y, bugDirection.z); - // would be nice to add some randomness here... - - // Generate voxels for where bug is going to - for (int i = 0; i < VOXELS_PER_BUG; i++) { - details[i].s = BUG_VOXEL_SIZE; - - glm::vec3 partAt = bugParts[i].partLocation * BUG_VOXEL_SIZE * (bugDirection.x < 0 ? -1.0f : 1.0f); - glm::vec3 rotatedPartAt = rotatePoint(partAt, bugRotation); - glm::vec3 offsetPartAt = rotatedPartAt + bugPosition; - - details[i].x = offsetPartAt.x; - details[i].y = offsetPartAt.y; - details[i].z = offsetPartAt.z; - - details[i].red = bugParts[i].partColor[0]; - details[i].green = bugParts[i].partColor[1]; - details[i].blue = bugParts[i].partColor[2]; - } - - // send the "create message" ... - message = PacketTypeVoxelSetDestructive; - ::voxelEditPacketSender->queueVoxelEditMessages(message, VOXELS_PER_BUG, (VoxelDetail*)&details); -} - - -float intensity = 0.5f; -float intensityIncrement = 0.1f; -const float MAX_INTENSITY = 1.0f; -const float MIN_INTENSITY = 0.5f; -const float BEACON_SIZE = 0.25f / TREE_SCALE; // approximately 1/4th meter - -static void sendVoxelBlinkMessage() { - VoxelDetail detail; - detail.s = BEACON_SIZE; - - glm::vec3 position = glm::vec3(0.f, 0.f, detail.s); - - detail.x = detail.s * floor(position.x / detail.s); - detail.y = detail.s * floor(position.y / detail.s); - detail.z = detail.s * floor(position.z / detail.s); - - ::intensity += ::intensityIncrement; - if (::intensity >= MAX_INTENSITY) { - ::intensity = MAX_INTENSITY; - ::intensityIncrement = -::intensityIncrement; - } - if (::intensity <= MIN_INTENSITY) { - ::intensity = MIN_INTENSITY; - ::intensityIncrement = -::intensityIncrement; - } - - detail.red = 255 * ::intensity; - detail.green = 0 * ::intensity; - detail.blue = 0 * ::intensity; - - PacketType message = PacketTypeVoxelSetDestructive; - - ::voxelEditPacketSender->sendVoxelEditMessage(message, detail); -} - -bool stringOfLightsInitialized = false; -int currentLight = 0; -int lightMovementDirection = 1; -const int SEGMENT_COUNT = 4; -const int LIGHTS_PER_SEGMENT = 80; -const int LIGHT_COUNT = LIGHTS_PER_SEGMENT * SEGMENT_COUNT; -glm::vec3 stringOfLights[LIGHT_COUNT]; -unsigned char offColor[3] = { 240, 240, 240 }; -unsigned char onColor[3] = { 0, 255, 255 }; -const float STRING_OF_LIGHTS_SIZE = 0.125f / TREE_SCALE; // approximately 1/8th meter - -static void sendBlinkingStringOfLights() { - PacketType message = PacketTypeVoxelSetDestructive; // we're a bully! - float lightScale = STRING_OF_LIGHTS_SIZE; - static VoxelDetail details[LIGHTS_PER_SEGMENT]; - - // first initialized the string of lights if needed... - if (!stringOfLightsInitialized) { - for (int segment = 0; segment < SEGMENT_COUNT; segment++) { - for (int indexInSegment = 0; indexInSegment < LIGHTS_PER_SEGMENT; indexInSegment++) { - - int i = (segment * LIGHTS_PER_SEGMENT) + indexInSegment; - - // four different segments on sides of initial platform - switch (segment) { - case 0: - // along x axis - stringOfLights[i] = glm::vec3(indexInSegment * lightScale, 0, 0); - break; - case 1: - // parallel to Z axis at outer X edge - stringOfLights[i] = glm::vec3(LIGHTS_PER_SEGMENT * lightScale, 0, indexInSegment * lightScale); - break; - case 2: - // parallel to X axis at outer Z edge - stringOfLights[i] = glm::vec3((LIGHTS_PER_SEGMENT-indexInSegment) * lightScale, 0, - LIGHTS_PER_SEGMENT * lightScale); - break; - case 3: - // on Z axis - stringOfLights[i] = glm::vec3(0, 0, (LIGHTS_PER_SEGMENT-indexInSegment) * lightScale); - break; - } - - details[indexInSegment].s = STRING_OF_LIGHTS_SIZE; - details[indexInSegment].x = stringOfLights[i].x; - details[indexInSegment].y = stringOfLights[i].y; - details[indexInSegment].z = stringOfLights[i].z; - - details[indexInSegment].red = offColor[0]; - details[indexInSegment].green = offColor[1]; - details[indexInSegment].blue = offColor[2]; - } - - ::voxelEditPacketSender->queueVoxelEditMessages(message, LIGHTS_PER_SEGMENT, (VoxelDetail*)&details); - } - stringOfLightsInitialized = true; - } else { - // turn off current light - details[0].x = stringOfLights[currentLight].x; - details[0].y = stringOfLights[currentLight].y; - details[0].z = stringOfLights[currentLight].z; - details[0].red = offColor[0]; - details[0].green = offColor[1]; - details[0].blue = offColor[2]; - - // move current light... - // if we're at the end of our string, then change direction - if (currentLight == LIGHT_COUNT-1) { - lightMovementDirection = -1; - } - if (currentLight == 0) { - lightMovementDirection = 1; - } - currentLight += lightMovementDirection; - - // turn on new current light - details[1].x = stringOfLights[currentLight].x; - details[1].y = stringOfLights[currentLight].y; - details[1].z = stringOfLights[currentLight].z; - details[1].red = onColor[0]; - details[1].green = onColor[1]; - details[1].blue = onColor[2]; - - // send both changes in same message - ::voxelEditPacketSender->queueVoxelEditMessages(message, 2, (VoxelDetail*)&details); - } -} - -bool danceFloorInitialized = false; -const float DANCE_FLOOR_LIGHT_SIZE = 1.0f / TREE_SCALE; // approximately 1 meter -const int DANCE_FLOOR_LENGTH = 10; -const int DANCE_FLOOR_WIDTH = 10; -glm::vec3 danceFloorPosition(100.0f / TREE_SCALE, 30.0f / TREE_SCALE, 10.0f / TREE_SCALE); -glm::vec3 danceFloorLights[DANCE_FLOOR_LENGTH][DANCE_FLOOR_WIDTH]; -unsigned char danceFloorOffColor[3] = { 240, 240, 240 }; -const int DANCE_FLOOR_COLORS = 6; - -unsigned char danceFloorOnColorA[DANCE_FLOOR_COLORS][3] = { - { 255, 0, 0 }, { 0, 255, 0 }, { 0, 0, 255 }, - { 0, 191, 255 }, { 0, 250, 154 }, { 255, 69, 0 }, -}; -unsigned char danceFloorOnColorB[DANCE_FLOOR_COLORS][3] = { - { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } , - { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } -}; -float danceFloorGradient = 0.5f; -const float BEATS_PER_MINUTE = 118.0f; -const float SECONDS_PER_MINUTE = 60.0f; -const float FRAMES_PER_BEAT = (SECONDS_PER_MINUTE * ANIMATE_FPS) / BEATS_PER_MINUTE; -float danceFloorGradientIncrement = 1.0f / FRAMES_PER_BEAT; -const float DANCE_FLOOR_MAX_GRADIENT = 1.0f; -const float DANCE_FLOOR_MIN_GRADIENT = 0.0f; -const int DANCE_FLOOR_VOXELS_PER_PACKET = 100; -int danceFloorColors[DANCE_FLOOR_WIDTH][DANCE_FLOOR_LENGTH]; - -void sendDanceFloor() { - PacketType message = PacketTypeVoxelSetDestructive; // we're a bully! - float lightScale = DANCE_FLOOR_LIGHT_SIZE; - static VoxelDetail details[DANCE_FLOOR_VOXELS_PER_PACKET]; - - // first initialized the billboard of lights if needed... - if (!::danceFloorInitialized) { - for (int i = 0; i < DANCE_FLOOR_WIDTH; i++) { - for (int j = 0; j < DANCE_FLOOR_LENGTH; j++) { - - int randomColorIndex = randIntInRange(-DANCE_FLOOR_COLORS, DANCE_FLOOR_COLORS); - ::danceFloorColors[i][j] = randomColorIndex; - ::danceFloorLights[i][j] = ::danceFloorPosition + - glm::vec3(i * DANCE_FLOOR_LIGHT_SIZE, 0, j * DANCE_FLOOR_LIGHT_SIZE); - } - } - ::danceFloorInitialized = true; - } - - ::danceFloorGradient += ::danceFloorGradientIncrement; - - if (::danceFloorGradient >= DANCE_FLOOR_MAX_GRADIENT) { - ::danceFloorGradient = DANCE_FLOOR_MAX_GRADIENT; - ::danceFloorGradientIncrement = -::danceFloorGradientIncrement; - } - if (::danceFloorGradient <= DANCE_FLOOR_MIN_GRADIENT) { - ::danceFloorGradient = DANCE_FLOOR_MIN_GRADIENT; - ::danceFloorGradientIncrement = -::danceFloorGradientIncrement; - } - - for (int i = 0; i < DANCE_FLOOR_LENGTH; i++) { - for (int j = 0; j < DANCE_FLOOR_WIDTH; j++) { - - int nthVoxel = ((i * DANCE_FLOOR_WIDTH) + j); - int item = nthVoxel % DANCE_FLOOR_VOXELS_PER_PACKET; - - ::danceFloorLights[i][j] = ::danceFloorPosition + - glm::vec3(i * DANCE_FLOOR_LIGHT_SIZE, 0, j * DANCE_FLOOR_LIGHT_SIZE); - - details[item].s = lightScale; - details[item].x = ::danceFloorLights[i][j].x; - details[item].y = ::danceFloorLights[i][j].y; - details[item].z = ::danceFloorLights[i][j].z; - - if (danceFloorColors[i][j] > 0) { - int color = danceFloorColors[i][j] - 1; - details[item].red = (::danceFloorOnColorA[color][0] + - ((::danceFloorOnColorB[color][0] - ::danceFloorOnColorA[color][0]) - * ::danceFloorGradient)); - details[item].green = (::danceFloorOnColorA[color][1] + - ((::danceFloorOnColorB[color][1] - ::danceFloorOnColorA[color][1]) - * ::danceFloorGradient)); - details[item].blue = (::danceFloorOnColorA[color][2] + - ((::danceFloorOnColorB[color][2] - ::danceFloorOnColorA[color][2]) - * ::danceFloorGradient)); - } else if (::danceFloorColors[i][j] < 0) { - int color = -(::danceFloorColors[i][j] + 1); - details[item].red = (::danceFloorOnColorB[color][0] + - ((::danceFloorOnColorA[color][0] - ::danceFloorOnColorB[color][0]) - * ::danceFloorGradient)); - details[item].green = (::danceFloorOnColorB[color][1] + - ((::danceFloorOnColorA[color][1] - ::danceFloorOnColorB[color][1]) - * ::danceFloorGradient)); - details[item].blue = (::danceFloorOnColorB[color][2] + - ((::danceFloorOnColorA[color][2] - ::danceFloorOnColorB[color][2]) - * ::danceFloorGradient)); - } else { - int color = 0; - details[item].red = (::danceFloorOnColorB[color][0] + - ((::danceFloorOnColorA[color][0] - ::danceFloorOnColorB[color][0]) - * ::danceFloorGradient)); - details[item].green = (::danceFloorOnColorB[color][1] + - ((::danceFloorOnColorA[color][1] - ::danceFloorOnColorB[color][1]) - * ::danceFloorGradient)); - details[item].blue = (::danceFloorOnColorB[color][2] + - ((::danceFloorOnColorA[color][2] - ::danceFloorOnColorB[color][2]) - * ::danceFloorGradient)); - } - - if (item == DANCE_FLOOR_VOXELS_PER_PACKET - 1) { - ::voxelEditPacketSender->queueVoxelEditMessages(message, DANCE_FLOOR_VOXELS_PER_PACKET, (VoxelDetail*)&details); - } - } - } -} - -bool billboardInitialized = false; -const int BILLBOARD_HEIGHT = 9; -const int BILLBOARD_WIDTH = 45; -glm::vec3 billboardPosition((0.125f / TREE_SCALE),(0.125f / TREE_SCALE),0); -glm::vec3 billboardLights[BILLBOARD_HEIGHT][BILLBOARD_WIDTH]; -unsigned char billboardOffColor[3] = { 240, 240, 240 }; -unsigned char billboardOnColorA[3] = { 0, 0, 255 }; -unsigned char billboardOnColorB[3] = { 0, 255, 0 }; -float billboardGradient = 0.5f; -float billboardGradientIncrement = 0.01f; -const float BILLBOARD_MAX_GRADIENT = 1.0f; -const float BILLBOARD_MIN_GRADIENT = 0.0f; -const float BILLBOARD_LIGHT_SIZE = 0.125f / TREE_SCALE; // approximately 1/8 meter per light -const int VOXELS_PER_PACKET = 81; - -// top to bottom... -bool billboardMessage[BILLBOARD_HEIGHT][BILLBOARD_WIDTH] = { - { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }, - { 0,0,1,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,1,1,1,1,0,0,0,0,0,1,0,1,1,1,0,1,0,1,0,0,1,0,0,0,0,0,0 }, - { 0,0,1,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,1,0,1,0,1,0,1,0,0,0,1,1,1,0,0,0,0,0 }, - { 0,0,1,1,1,1,0,1,0,1,1,1,0,1,1,1,0,0,1,1,1,0,0,0,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,0,1,0,1,0 }, - { 0,0,1,0,0,1,0,1,0,1,0,1,0,1,0,1,0,0,1,0,0,0,0,1,0,1,0,1,0,1,0,0,0,1,0,1,0,0,1,0,0,1,0,1,0 }, - { 0,0,1,0,0,1,0,1,0,1,1,1,0,1,0,1,0,0,1,0,0,0,0,1,0,1,1,1,0,1,1,1,0,1,0,1,0,0,1,0,0,1,1,1,0 }, - { 0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0 }, - { 0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0 }, - { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } -}; - -static void sendBillboard() { - PacketType message = PacketTypeVoxelSetDestructive; // we're a bully! - float lightScale = BILLBOARD_LIGHT_SIZE; - static VoxelDetail details[VOXELS_PER_PACKET]; - - // first initialized the billboard of lights if needed... - if (!billboardInitialized) { - for (int i = 0; i < BILLBOARD_HEIGHT; i++) { - for (int j = 0; j < BILLBOARD_WIDTH; j++) { - - billboardLights[i][j] = billboardPosition + glm::vec3(j * lightScale, (float)((BILLBOARD_HEIGHT - i) * lightScale), 0); - } - } - billboardInitialized = true; - } - - ::billboardGradient += ::billboardGradientIncrement; - - if (::billboardGradient >= BILLBOARD_MAX_GRADIENT) { - ::billboardGradient = BILLBOARD_MAX_GRADIENT; - ::billboardGradientIncrement = -::billboardGradientIncrement; - } - if (::billboardGradient <= BILLBOARD_MIN_GRADIENT) { - ::billboardGradient = BILLBOARD_MIN_GRADIENT; - ::billboardGradientIncrement = -::billboardGradientIncrement; - } - - for (int i = 0; i < BILLBOARD_HEIGHT; i++) { - for (int j = 0; j < BILLBOARD_WIDTH; j++) { - - int nthVoxel = ((i * BILLBOARD_WIDTH) + j); - int item = nthVoxel % VOXELS_PER_PACKET; - - billboardLights[i][j] = billboardPosition + glm::vec3(j * lightScale, (float)((BILLBOARD_HEIGHT - i) * lightScale), 0); - - details[item].s = lightScale; - details[item].x = billboardLights[i][j].x; - details[item].y = billboardLights[i][j].y; - details[item].z = billboardLights[i][j].z; - - if (billboardMessage[i][j]) { - details[item].red = (billboardOnColorA[0] + ((billboardOnColorB[0] - billboardOnColorA[0]) * ::billboardGradient)); - details[item].green = (billboardOnColorA[1] + ((billboardOnColorB[1] - billboardOnColorA[1]) * ::billboardGradient)); - details[item].blue = (billboardOnColorA[2] + ((billboardOnColorB[2] - billboardOnColorA[2]) * ::billboardGradient)); - } else { - details[item].red = billboardOffColor[0]; - details[item].green = billboardOffColor[1]; - details[item].blue = billboardOffColor[2]; - } - - if (item == VOXELS_PER_PACKET - 1) { - ::voxelEditPacketSender->queueVoxelEditMessages(message, VOXELS_PER_PACKET, (VoxelDetail*)&details); - } - } - } -} - -bool roadInitialized = false; -const int BRICKS_ACROSS_ROAD = 32; -const float ROAD_BRICK_SIZE = 0.125f/TREE_SCALE; //(ROAD_WIDTH_METERS / TREE_SCALE) / BRICKS_ACROSS_ROAD; // in voxel units -const int ROAD_LENGTH = 1.0f / ROAD_BRICK_SIZE; // in bricks -const int ROAD_WIDTH = BRICKS_ACROSS_ROAD; // in bricks -glm::vec3 roadPosition(0.5f - (ROAD_BRICK_SIZE * BRICKS_ACROSS_ROAD), 0.0f, 0.0f); -const int BRICKS_PER_PACKET = 32; // guessing - -void doBuildStreet() { - if (roadInitialized) { - return; - } - - PacketType message = PacketTypeVoxelSetDestructive; // we're a bully! - static VoxelDetail details[BRICKS_PER_PACKET]; - - for (int z = 0; z < ROAD_LENGTH; z++) { - for (int x = 0; x < ROAD_WIDTH; x++) { - - int nthVoxel = ((z * ROAD_WIDTH) + x); - int item = nthVoxel % BRICKS_PER_PACKET; - - glm::vec3 brick = roadPosition + glm::vec3(x * ROAD_BRICK_SIZE, 0, z * ROAD_BRICK_SIZE); - - details[item].s = ROAD_BRICK_SIZE; - details[item].x = brick.x; - details[item].y = brick.y; - details[item].z = brick.z; - - unsigned char randomTone = randIntInRange(118,138); - details[item].red = randomTone; - details[item].green = randomTone; - details[item].blue = randomTone; - - if (item == BRICKS_PER_PACKET - 1) { - ::voxelEditPacketSender->queueVoxelEditMessages(message, BRICKS_PER_PACKET, (VoxelDetail*)&details); - } - } - } - roadInitialized = true; -} - - -double start = 0; - - -void* animateVoxels(void* args) { - - quint64 lastAnimateTime = 0; - quint64 lastProcessTime = 0; - int processesPerAnimate = 0; - - bool firstTime = true; - - qDebug() << "Setting PPS to " << ::packetsPerSecond; - ::voxelEditPacketSender->setPacketsPerSecond(::packetsPerSecond); - - qDebug() << "PPS set to " << ::voxelEditPacketSender->getPacketsPerSecond(); - - while (true) { - - // If we're asked to wait for voxel servers, and there isn't one available yet, then - // let the voxelEditPacketSender process and move on. - if (::waitForVoxelServer && !::voxelEditPacketSender->voxelServersExist()) { - if (::nonThreadedPacketSender) { - ::voxelEditPacketSender->process(); - } - } else { - if (firstTime) { - lastAnimateTime = usecTimestampNow(); - firstTime = false; - } - lastProcessTime = usecTimestampNow(); - - // The while loop will be running at PROCESSING_FPS, but we only want to call these animation functions at - // ANIMATE_FPS. So we check out last animate time and only call these if we've elapsed that time. - quint64 now = usecTimestampNow(); - quint64 animationElapsed = now - lastAnimateTime; - int withinAnimationTarget = ANIMATE_VOXELS_INTERVAL_USECS - animationElapsed; - const int CLOSE_ENOUGH_TO_ANIMATE = 2000; // approximately 2 ms - - int animateLoopsPerAnimate = 0; - while (withinAnimationTarget < CLOSE_ENOUGH_TO_ANIMATE) { - processesPerAnimate = 0; - animateLoopsPerAnimate++; - - lastAnimateTime = now; - // some animations - //sendVoxelBlinkMessage(); - - if (::includeBillboard) { - sendBillboard(); - } - if (::includeBorderTracer) { - sendBlinkingStringOfLights(); - } - if (::includeMovingBug) { - renderMovingBug(); - } - if (::includeBlinkingVoxel) { - sendVoxelBlinkMessage(); - } - if (::includeDanceFloor) { - sendDanceFloor(); - } - - if (::buildStreet) { - doBuildStreet(); - } - - if (animationElapsed > ANIMATE_VOXELS_INTERVAL_USECS) { - animationElapsed -= ANIMATE_VOXELS_INTERVAL_USECS; // credit ourselves one animation frame - } else { - animationElapsed = 0; - } - withinAnimationTarget = ANIMATE_VOXELS_INTERVAL_USECS - animationElapsed; - - ::voxelEditPacketSender->releaseQueuedMessages(); - } - - if (::nonThreadedPacketSender) { - ::voxelEditPacketSender->process(); - } - processesPerAnimate++; - } - // dynamically sleep until we need to fire off the next set of voxels - quint64 usecToSleep = ::PROCESSING_INTERVAL_USECS - (usecTimestampNow() - lastProcessTime); - if (usecToSleep > ::PROCESSING_INTERVAL_USECS) { - usecToSleep = ::PROCESSING_INTERVAL_USECS; - } - - if (usecToSleep > 0) { - usleep(usecToSleep); - } - } - - pthread_exit(0); -} - -AnimationServer::AnimationServer(int &argc, char **argv) : - QCoreApplication(argc, argv) -{ - ::start = usecTimestampNow(); - - NodeList* nodeList = NodeList::createInstance(NodeType::AnimationServer, ANIMATION_LISTEN_PORT); - setvbuf(stdout, NULL, _IOLBF, 0); - - // Handle Local Domain testing with the --local command line - const char* NON_THREADED_PACKETSENDER = "--NonThreadedPacketSender"; - ::nonThreadedPacketSender = cmdOptionExists(argc, (const char**) argv, NON_THREADED_PACKETSENDER); - qDebug("nonThreadedPacketSender=%s", debug::valueOf(::nonThreadedPacketSender)); - - // Handle Local Domain testing with the --local command line - const char* NO_BILLBOARD = "--NoBillboard"; - ::includeBillboard = !cmdOptionExists(argc, (const char**) argv, NO_BILLBOARD); - qDebug("includeBillboard=%s", debug::valueOf(::includeBillboard)); - - const char* NO_BORDER_TRACER = "--NoBorderTracer"; - ::includeBorderTracer = !cmdOptionExists(argc, (const char**) argv, NO_BORDER_TRACER); - qDebug("includeBorderTracer=%s", debug::valueOf(::includeBorderTracer)); - - const char* NO_MOVING_BUG = "--NoMovingBug"; - ::includeMovingBug = !cmdOptionExists(argc, (const char**) argv, NO_MOVING_BUG); - qDebug("includeMovingBug=%s", debug::valueOf(::includeMovingBug)); - - const char* INCLUDE_BLINKING_VOXEL = "--includeBlinkingVoxel"; - ::includeBlinkingVoxel = cmdOptionExists(argc, (const char**) argv, INCLUDE_BLINKING_VOXEL); - qDebug("includeBlinkingVoxel=%s", debug::valueOf(::includeBlinkingVoxel)); - - const char* NO_DANCE_FLOOR = "--NoDanceFloor"; - ::includeDanceFloor = !cmdOptionExists(argc, (const char**) argv, NO_DANCE_FLOOR); - qDebug("includeDanceFloor=%s", debug::valueOf(::includeDanceFloor)); - - const char* BUILD_STREET = "--BuildStreet"; - ::buildStreet = cmdOptionExists(argc, (const char**) argv, BUILD_STREET); - qDebug("buildStreet=%s", debug::valueOf(::buildStreet)); - - // Handle Local Domain testing with the --local command line - const char* showPPS = "--showPPS"; - ::shouldShowPacketsPerSecond = cmdOptionExists(argc, (const char**) argv, showPPS); - - // Handle Local Domain testing with the --local command line - const char* local = "--local"; - ::wantLocalDomain = cmdOptionExists(argc, (const char**) argv,local); - if (::wantLocalDomain) { - qDebug("Local Domain MODE!"); - nodeList->getDomainHandler().setIPToLocalhost(); - } - - const char* domainHostname = getCmdOption(argc, (const char**) argv, "--domain"); - if (domainHostname) { - NodeList::getInstance()->getDomainHandler().setHostname(domainHostname); - } - - const char* packetsPerSecondCommand = getCmdOption(argc, (const char**) argv, "--pps"); - if (packetsPerSecondCommand) { - ::packetsPerSecond = atoi(packetsPerSecondCommand); - } - qDebug("packetsPerSecond=%d",packetsPerSecond); - - const char* animateFPSCommand = getCmdOption(argc, (const char**) argv, "--AnimateFPS"); - const char* animateIntervalCommand = getCmdOption(argc, (const char**) argv, "--AnimateInterval"); - if (animateFPSCommand || animateIntervalCommand) { - if (animateIntervalCommand) { - ::ANIMATE_FPS_IN_MILLISECONDS = atoi(animateIntervalCommand); - ::ANIMATE_VOXELS_INTERVAL_USECS = (ANIMATE_FPS_IN_MILLISECONDS * 1000.0); // converts from milliseconds to usecs - ::ANIMATE_FPS = PacketSender::USECS_PER_SECOND / ::ANIMATE_VOXELS_INTERVAL_USECS; - } else { - ::ANIMATE_FPS = atoi(animateFPSCommand); - ::ANIMATE_FPS_IN_MILLISECONDS = 1000.0/ANIMATE_FPS; // determines FPS from our desired FPS - ::ANIMATE_VOXELS_INTERVAL_USECS = (ANIMATE_FPS_IN_MILLISECONDS * 1000.0); // converts from milliseconds to usecs - } - } - qDebug("ANIMATE_FPS=%d",ANIMATE_FPS); - qDebug("ANIMATE_VOXELS_INTERVAL_USECS=%llu",ANIMATE_VOXELS_INTERVAL_USECS); - - const char* processingFPSCommand = getCmdOption(argc, (const char**) argv, "--ProcessingFPS"); - const char* processingIntervalCommand = getCmdOption(argc, (const char**) argv, "--ProcessingInterval"); - if (processingFPSCommand || processingIntervalCommand) { - if (processingIntervalCommand) { - ::PROCESSING_FPS_IN_MILLISECONDS = atoi(processingIntervalCommand); - ::PROCESSING_INTERVAL_USECS = ::PROCESSING_FPS_IN_MILLISECONDS * 1000.0; - ::PROCESSING_FPS = PacketSender::USECS_PER_SECOND / ::PROCESSING_INTERVAL_USECS; - } else { - ::PROCESSING_FPS = atoi(processingFPSCommand); - ::PROCESSING_FPS_IN_MILLISECONDS = 1000.0/PROCESSING_FPS; // determines FPS from our desired FPS - ::PROCESSING_INTERVAL_USECS = (PROCESSING_FPS_IN_MILLISECONDS * 1000.0) - FUDGE_USECS; // converts from milliseconds to usecs - } - } - qDebug("PROCESSING_FPS=%d",PROCESSING_FPS); - qDebug("PROCESSING_INTERVAL_USECS=%llu",PROCESSING_INTERVAL_USECS); - - nodeList->linkedDataCreateCallback = NULL; // do we need a callback? - - // Create our JurisdictionListener so we'll know where to send edit packets - ::jurisdictionListener = new JurisdictionListener(); - if (::jurisdictionListener) { - ::jurisdictionListener->initialize(true); - } - - // Create out VoxelEditPacketSender - ::voxelEditPacketSender = new VoxelEditPacketSender; - ::voxelEditPacketSender->initialize(!::nonThreadedPacketSender); - - if (::jurisdictionListener) { - ::voxelEditPacketSender->setVoxelServerJurisdictions(::jurisdictionListener->getJurisdictions()); - } - if (::nonThreadedPacketSender) { - ::voxelEditPacketSender->setProcessCallIntervalHint(PROCESSING_INTERVAL_USECS); - } - - srand((unsigned)time(0)); - - - pthread_create(&::animateVoxelThread, NULL, animateVoxels, NULL); - - NodeList::getInstance()->addNodeTypeToInterestSet(NodeType::VoxelServer); - - QTimer* domainServerTimer = new QTimer(this); - connect(domainServerTimer, SIGNAL(timeout()), nodeList, SLOT(sendDomainServerCheckIn())); - domainServerTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS); - - QTimer* silentNodeTimer = new QTimer(this); - connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes())); - silentNodeTimer->start(NODE_SILENCE_THRESHOLD_MSECS); - - connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), SLOT(readPendingDatagrams())); -} - -void AnimationServer::readPendingDatagrams() { - NodeList* nodeList = NodeList::getInstance(); - - static QByteArray receivedPacket; - static HifiSockAddr nodeSockAddr; - - // Nodes sending messages to us... - while (nodeList->getNodeSocket().hasPendingDatagrams()) { - receivedPacket.resize(nodeList->getNodeSocket().pendingDatagramSize()); - nodeList->getNodeSocket().readDatagram(receivedPacket.data(), receivedPacket.size(), - nodeSockAddr.getAddressPointer(), nodeSockAddr.getPortPointer()); - if (nodeList->packetVersionAndHashMatch(receivedPacket)) { - if (packetTypeForPacket(receivedPacket) == PacketTypeJurisdiction) { - int headerBytes = numBytesForPacketHeader(receivedPacket); - // PacketType_JURISDICTION, first byte is the node type... - if (receivedPacket.data()[headerBytes] == NodeType::VoxelServer && ::jurisdictionListener) { - - SharedNodePointer matchedNode = NodeList::getInstance()->sendingNodeForPacket(receivedPacket); - if (matchedNode) { - ::jurisdictionListener->queueReceivedPacket(matchedNode, receivedPacket); - } - } - } - NodeList::getInstance()->processNodeData(nodeSockAddr, receivedPacket); - } - } -} - -AnimationServer::~AnimationServer() { - pthread_join(animateVoxelThread, NULL); - - if (::jurisdictionListener) { - ::jurisdictionListener->terminate(); - delete ::jurisdictionListener; - } - - if (::voxelEditPacketSender) { - ::voxelEditPacketSender->terminate(); - delete ::voxelEditPacketSender; - } -} diff --git a/animation-server/src/AnimationServer.h b/animation-server/src/AnimationServer.h deleted file mode 100644 index 58f05c32c5..0000000000 --- a/animation-server/src/AnimationServer.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// AnimationServer.h -// animation-server/src -// -// Created by Stephen Birarda on 12/5/2013. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_AnimationServer_h -#define hifi_AnimationServer_h - -#include - -class AnimationServer : public QCoreApplication { - Q_OBJECT -public: - AnimationServer(int &argc, char **argv); - ~AnimationServer(); -private slots: - void readPendingDatagrams(); -}; - - -#endif // hifi_AnimationServer_h diff --git a/animation-server/src/main.cpp b/animation-server/src/main.cpp deleted file mode 100644 index 8acf3b8db2..0000000000 --- a/animation-server/src/main.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// -// main.cpp -// animation-server/src -// -// Created by Brad Hefta-Gaub on 05/16/2013. -// Copyright 2012 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "AnimationServer.h" - -int main(int argc, char * argv[]) { - AnimationServer animationServer(argc, argv); - return animationServer.exec(); -} diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 5ca021b175..fec0aedfdd 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -6,8 +6,6 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros") # setup for find modules set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") -find_package(Qt5 COMPONENTS Network Script Widgets) - include("${MACRO_DIR}/SetupHifiProject.cmake") setup_hifi_project(${TARGET_NAME} TRUE) @@ -39,8 +37,6 @@ IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) ENDIF(WIN32) -target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script) - # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/cmake/macros/LinkHifiLibrary.cmake b/cmake/macros/LinkHifiLibrary.cmake index 577f0c9f37..0728abf8c9 100644 --- a/cmake/macros/LinkHifiLibrary.cmake +++ b/cmake/macros/LinkHifiLibrary.cmake @@ -16,12 +16,10 @@ macro(LINK_HIFI_LIBRARY LIBRARY TARGET ROOT_DIR) include_directories("${ROOT_DIR}/libraries/${LIBRARY}/src") add_dependencies(${TARGET} ${LIBRARY}) + target_link_libraries(${TARGET} ${LIBRARY} ${REQUIRED_DEPENDENCY_LIBRARIES}) - if (APPLE) - # currently the "shared" library requires CoreServices - # link in required OS X framework - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework CoreServices") + if (REQUIRED_DEPENDENCY_QT_MODULES) + qt5_use_modules(${TARGET_NAME} ${REQUIRED_DEPENDENCY_QT_MODULES}) endif () - endmacro(LINK_HIFI_LIBRARY _library _target _root_dir) \ No newline at end of file diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 9a13374a4f..8f8366d4d3 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -4,8 +4,6 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros") set(TARGET_NAME networking) project(${TARGET_NAME}) -find_package(Qt5 COMPONENTS Network) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -13,7 +11,10 @@ setup_hifi_library(${TARGET_NAME}) include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -target_link_libraries(${TARGET_NAME} Qt5::Network) +find_package(Qt5Network REQUIRED) +set(DEPENDENCY_QT_MODULES Network) +set(REQUIRED_DEPENDENCY_QT_MODULES ${DEPENDENCY_QT_MODULES} PARENT_SCOPE) +qt5_use_modules(${TARGET_NAME} ${DEPENDENCY_QT_MODULES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index 398bf80157..99da8d1bf2 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -6,8 +6,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME octree) -find_package(Qt5Widgets REQUIRED) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -26,7 +24,7 @@ include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") # bubble up the libraries we are dependent on set(REQUIRED_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} - "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}" Qt5::Widgets PARENT_SCOPE) + "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}" PARENT_SCOPE) target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index c0d59c8b75..f7f05c88a7 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -4,7 +4,8 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros") set(TARGET_NAME shared) project(${TARGET_NAME}) -find_package(Qt5 COMPONENTS Network Widgets Xml Script) +find_package(Qt5 COMPONENTS Network) +find_package(Qt5Widgets REQUIRED) include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -21,16 +22,15 @@ if (WIN32) endif (WIN32) # link required libraries on UNIX -if (UNIX AND NOT APPLE) - find_package(Threads REQUIRED) - target_link_libraries(${TARGET_NAME} "${CMAKE_THREAD_LIBS_INIT}") -endif (UNIX AND NOT APPLE) - -# There is something special (bug) about Qt5Scripts, that we have to explicitly add its include -# directory when Qt5 (5.2.1) is compiled from source and is not in a standard place. -include_directories(SYSTEM "${Qt5Script_INCLUDE_DIRS}") +if (APPLE) + find_library(CoreServices CoreServices) + list(APPEND REQUIRED_DEPENDENCY_LIBRARIES ${CoreServices}) +elseif (UNIX) + find_package(Threads REQUIRED) + LIST(APPEND REQUIRED_DEPENDENCY_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") +endif () # bubble up the libraries we are dependent on and link them to ourselves -set(REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) +list(APPEND REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) \ No newline at end of file From fa26957b230051b8af7c447d861f7c0900191ea2 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 15:20:26 -0700 Subject: [PATCH 04/43] more CMakeLists cleanup for sub-dependencies --- assignment-client/CMakeLists.txt | 4 - cmake/macros/LinkHifiLibrary.cmake | 6 +- domain-server/CMakeLists.txt | 13 - libraries/animation/CMakeLists.txt | 10 +- libraries/avatars/CMakeLists.txt | 5 - libraries/embedded-webserver/CMakeLists.txt | 9 +- libraries/networking/CMakeLists.txt | 10 +- libraries/particles/CMakeLists.txt | 8 - libraries/shared/CMakeLists.txt | 13 +- libraries/shared/external/pthread.h | 1403 ------------------- libraries/shared/external/sched.h | 189 --- 11 files changed, 18 insertions(+), 1652 deletions(-) delete mode 100644 libraries/shared/external/pthread.h delete mode 100644 libraries/shared/external/sched.h diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index fec0aedfdd..a4e26899fb 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -9,10 +9,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake include("${MACRO_DIR}/SetupHifiProject.cmake") setup_hifi_project(${TARGET_NAME} TRUE) -# include glm -include("${MACRO_DIR}/IncludeGLM.cmake") -include_glm(${TARGET_NAME} "${ROOT_DIR}") - # link in the shared libraries include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") diff --git a/cmake/macros/LinkHifiLibrary.cmake b/cmake/macros/LinkHifiLibrary.cmake index 0728abf8c9..afb1f1febd 100644 --- a/cmake/macros/LinkHifiLibrary.cmake +++ b/cmake/macros/LinkHifiLibrary.cmake @@ -17,9 +17,5 @@ macro(LINK_HIFI_LIBRARY LIBRARY TARGET ROOT_DIR) add_dependencies(${TARGET} ${LIBRARY}) - target_link_libraries(${TARGET} ${LIBRARY} ${REQUIRED_DEPENDENCY_LIBRARIES}) - - if (REQUIRED_DEPENDENCY_QT_MODULES) - qt5_use_modules(${TARGET_NAME} ${REQUIRED_DEPENDENCY_QT_MODULES}) - endif () + target_link_libraries(${TARGET} ${LIBRARY} ${SUB_DEPENDENCY_LIBRARIES}) endmacro(LINK_HIFI_LIBRARY _library _target _root_dir) \ No newline at end of file diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 6ee794f7c6..26f07cf776 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -1,7 +1,3 @@ -if (WIN32) - cmake_policy (SET CMP0020 NEW) -endif (WIN32) - set(TARGET_NAME domain-server) set(ROOT_DIR ..) @@ -10,12 +6,6 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros") # setup for find modules set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") -# set up the external glm library -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -find_package(Qt5Network REQUIRED) - include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) @@ -39,9 +29,6 @@ IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) ENDIF(WIN32) -# link QtNetwork -target_link_libraries(${TARGET_NAME} Qt5::Network) - # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index b1dc59fff8..be6ed47898 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -6,22 +6,16 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME animation) -find_package(Qt5Widgets REQUIRED) +find_package(Qt5 COMPONENTS Script) include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -# link ZLIB -find_package(ZLIB) - -target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets) +target_link_libraries(${TARGET_NAME} Qt5::Script) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index ca4a2630b4..feb1e68557 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -6,8 +6,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME avatars) -find_package(Qt5Script REQUIRED) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -17,13 +15,10 @@ include_glm(${TARGET_NAME} "${ROOT_DIR}") include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -# link in the hifi voxels library link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -target_link_libraries(${TARGET_NAME} Qt5::Script) - # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/libraries/embedded-webserver/CMakeLists.txt b/libraries/embedded-webserver/CMakeLists.txt index 1386bcc392..f1681cdd12 100644 --- a/libraries/embedded-webserver/CMakeLists.txt +++ b/libraries/embedded-webserver/CMakeLists.txt @@ -6,9 +6,12 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME embedded-webserver) -find_package(Qt5Network REQUIRED) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -target_link_libraries(${TARGET_NAME} Qt5::Network) \ No newline at end of file +find_package(Qt5Network REQUIRED) + +# bubble up the libraries we are dependent on and link them to ourselves +set(REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network) +set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) +target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) \ No newline at end of file diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 8f8366d4d3..215d406133 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -11,10 +11,12 @@ setup_hifi_library(${TARGET_NAME}) include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -find_package(Qt5Network REQUIRED) -set(DEPENDENCY_QT_MODULES Network) -set(REQUIRED_DEPENDENCY_QT_MODULES ${DEPENDENCY_QT_MODULES} PARENT_SCOPE) -qt5_use_modules(${TARGET_NAME} ${DEPENDENCY_QT_MODULES}) +find_package(Qt5Network) + +# bubble up the libraries we are dependent on and link them to ourselves +set(REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network) +set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) +target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index 76b3373466..cecbdaaa21 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -6,8 +6,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME particles) -find_package(Qt5Widgets REQUIRED) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -21,12 +19,6 @@ link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") -# link ZLIB -find_package(ZLIB) - -include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets) - # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index f7f05c88a7..067551ba31 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -4,9 +4,6 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros") set(TARGET_NAME shared) project(${TARGET_NAME}) -find_package(Qt5 COMPONENTS Network) -find_package(Qt5Widgets REQUIRED) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -14,13 +11,6 @@ setup_hifi_library(${TARGET_NAME}) include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -set(EXTERNAL_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external") - -if (WIN32) - # include headers for external libraries and InterfaceConfig. - include_directories("${EXTERNAL_ROOT_DIR}") -endif (WIN32) - # link required libraries on UNIX if (APPLE) find_library(CoreServices CoreServices) @@ -30,6 +20,9 @@ elseif (UNIX) LIST(APPEND REQUIRED_DEPENDENCY_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") endif () +find_package(Qt5Network) +find_package(Qt5Widgets) + # bubble up the libraries we are dependent on and link them to ourselves list(APPEND REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) diff --git a/libraries/shared/external/pthread.h b/libraries/shared/external/pthread.h deleted file mode 100644 index f910eb4b0e..0000000000 --- a/libraries/shared/external/pthread.h +++ /dev/null @@ -1,1403 +0,0 @@ -/* This is an implementation of the threads API of POSIX 1003.1-2001. - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * The current list of contributors is contained - * in the file CONTRIBUTORS included with the source - * code distribution. The list can also be seen at the - * following World Wide Web location: - * http://sources.redhat.com/pthreads-win32/contributors.html - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library in the file COPYING.LIB; - * if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -#if !defined( PTHREAD_H ) -#define PTHREAD_H - -#define PTW32_STATIC_LIB - -/* - * See the README file for an explanation of the pthreads-win32 version - * numbering scheme and how the DLL is named etc. - */ -#define PTW32_VERSION 2,10,0,0 -#define PTW32_VERSION_STRING "2, 10, 0, 0\0" - -/* There are three implementations of cancel cleanup. - * Note that pthread.h is included in both application - * compilation units and also internally for the library. - * The code here and within the library aims to work - * for all reasonable combinations of environments. - * - * The three implementations are: - * - * WIN32 SEH - * C - * C++ - * - * Please note that exiting a push/pop block via - * "return", "exit", "break", or "continue" will - * lead to different behaviour amongst applications - * depending upon whether the library was built - * using SEH, C++, or C. For example, a library built - * with SEH will call the cleanup routine, while both - * C++ and C built versions will not. - */ - -/* - * Define defaults for cleanup code. - * Note: Unless the build explicitly defines one of the following, then - * we default to standard C style cleanup. This style uses setjmp/longjmp - * in the cancellation and thread exit implementations and therefore won't - * do stack unwinding if linked to applications that have it (e.g. - * C++ apps). This is currently consistent with most/all commercial Unix - * POSIX threads implementations. - */ -#if !defined( __CLEANUP_SEH ) && !defined( __CLEANUP_CXX ) && !defined( __CLEANUP_C ) -/* - [i_a] fix for apps using pthreads-Win32: when they do not define __CLEANUP_SEH themselves, - they're screwed as they'll receive the '__CLEANUP_C' macros which do NOT work when - the pthreads library code itself has actually been build with __CLEANUP_SEH, - which is the case when building this stuff in MSVC. - - Hence this section is made to 'sensibly autodetect' the cleanup mode, when it hasn't - been hardwired in the makefiles / project files. - - After all, who expects he MUST define one of these __CLEANUP_XXX defines in his own - code when using pthreads-Win32, for whatever reason. - */ -#if (defined(_MSC_VER) || defined(PTW32_RC_MSC)) -#define __CLEANUP_SEH -#elif defined(__cplusplus) -#define __CLEANUP_CXX -#else -#define __CLEANUP_C -#endif -#endif - -#if defined( __CLEANUP_SEH ) && ( !defined( _MSC_VER ) && !defined(PTW32_RC_MSC)) -#error ERROR [__FILE__, line __LINE__]: SEH is not supported for this compiler. -#endif - -/* - * Stop here if we are being included by the resource compiler. - */ -#if !defined(RC_INVOKED) - -#undef PTW32_LEVEL - -#if defined(_POSIX_SOURCE) -#define PTW32_LEVEL 0 -/* Early POSIX */ -#endif - -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_LEVEL -#define PTW32_LEVEL 1 -/* Include 1b, 1c and 1d */ -#endif - -#if defined(INCLUDE_NP) -#undef PTW32_LEVEL -#define PTW32_LEVEL 2 -/* Include Non-Portable extensions */ -#endif - -#define PTW32_LEVEL_MAX 3 - -#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_LEVEL) -#define PTW32_LEVEL PTW32_LEVEL_MAX -/* Include everything */ -#endif - -#if defined(_UWIN) -# define HAVE_STRUCT_TIMESPEC 1 -# define HAVE_SIGNAL_H 1 -# undef HAVE_PTW32_CONFIG_H -# pragma comment(lib, "pthread") -#endif - -#if defined(__MINGW32__) || defined(__MINGW64__) -# define PTW32_CONFIG_MINGW -#endif -#if defined(_MSC_VER) -# if _MSC_VER < 1300 -# define PTW32_CONFIG_MSVC6 -# endif -# if _MSC_VER < 1400 -# define PTW32_CONFIG_MSVC7 -# endif -#endif - -/* - * ------------------------------------------------------------- - * - * - * Module: pthread.h - * - * Purpose: - * Provides an implementation of PThreads based upon the - * standard: - * - * POSIX 1003.1-2001 - * and - * The Single Unix Specification version 3 - * - * (these two are equivalent) - * - * in order to enhance code portability between Windows, - * various commercial Unix implementations, and Linux. - * - * See the ANNOUNCE file for a full list of conforming - * routines and defined constants, and a list of missing - * routines and constants not defined in this implementation. - * - * Authors: - * There have been many contributors to this library. - * The initial implementation was contributed by - * John Bossom, and several others have provided major - * sections or revisions of parts of the implementation. - * Often significant effort has been contributed to - * find and fix important bugs and other problems to - * improve the reliability of the library, which sometimes - * is not reflected in the amount of code which changed as - * result. - * As much as possible, the contributors are acknowledged - * in the ChangeLog file in the source code distribution - * where their changes are noted in detail. - * - * Contributors are listed in the CONTRIBUTORS file. - * - * As usual, all bouquets go to the contributors, and all - * brickbats go to the project maintainer. - * - * Maintainer: - * The code base for this project is coordinated and - * eventually pre-tested, packaged, and made available by - * - * Ross Johnson - * - * QA Testers: - * Ultimately, the library is tested in the real world by - * a host of competent and demanding scientists and - * engineers who report bugs and/or provide solutions - * which are then fixed or incorporated into subsequent - * versions of the library. Each time a bug is fixed, a - * test case is written to prove the fix and ensure - * that later changes to the code don't reintroduce the - * same error. The number of test cases is slowly growing - * and therefore so is the code reliability. - * - * Compliance: - * See the file ANNOUNCE for the list of implemented - * and not-implemented routines and defined options. - * Of course, these are all defined is this file as well. - * - * Web site: - * The source code and other information about this library - * are available from - * - * http://sources.redhat.com/pthreads-win32/ - * - * ------------------------------------------------------------- - */ - -/* Try to avoid including windows.h */ -#if defined(PTW32_CONFIG_MINGW) && defined(__cplusplus) -#define PTW32_INCLUDE_WINDOWS_H -#endif - -#if defined(PTW32_INCLUDE_WINDOWS_H) -#include -#endif - -#if defined(PTW32_CONFIG_MSVC6) || defined(__DMC__) -/* - * VC++6.0 or early compiler's header has no DWORD_PTR type. - */ -typedef unsigned long DWORD_PTR; -typedef unsigned long ULONG_PTR; -#endif -/* - * ----------------- - * autoconf switches - * ----------------- - */ - -#if defined(HAVE_PTW32_CONFIG_H) -#include "config.h" -#endif /* HAVE_PTW32_CONFIG_H */ - -#if !defined(NEED_FTIME) -#include -#else /* NEED_FTIME */ -/* use native WIN32 time API */ -#endif /* NEED_FTIME */ - -#if defined(HAVE_SIGNAL_H) -#include -#endif /* HAVE_SIGNAL_H */ - -#include - -/* - * Boolean values to make us independent of system includes. - */ -enum { - PTW32_FALSE = 0, - PTW32_TRUE = (! PTW32_FALSE) -}; - -/* - * This is a duplicate of what is in the autoconf config.h, - * which is only used when building the pthread-win32 libraries. - */ - -#if !defined(PTW32_CONFIG_H) -# if defined(WINCE) -# define NEED_ERRNO -# define NEED_SEM -# endif -# if defined(__MINGW64__) -# define HAVE_STRUCT_TIMESPEC -# define HAVE_MODE_T -# elif defined(_UWIN) || defined(__MINGW32__) -# define HAVE_MODE_T -# endif -#endif - -/* - * - */ - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -#if defined(NEED_ERRNO) -#include "need_errno.h" -#else -#include -#endif -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -/* - * Several systems don't define some error numbers. - */ -#if !defined(ENOTSUP) -# define ENOTSUP 48 /* This is the value in Solaris. */ -#endif - -#if !defined(ETIMEDOUT) -# define ETIMEDOUT 10060 /* Same as WSAETIMEDOUT */ -#endif - -#if !defined(ENOSYS) -# define ENOSYS 140 /* Semi-arbitrary value */ -#endif - -#if !defined(EDEADLK) -# if defined(EDEADLOCK) -# define EDEADLK EDEADLOCK -# else -# define EDEADLK 36 /* This is the value in MSVC. */ -# endif -#endif - -/* POSIX 2008 - related to robust mutexes */ -#if !defined(EOWNERDEAD) -# define EOWNERDEAD 43 -#endif -#if !defined(ENOTRECOVERABLE) -# define ENOTRECOVERABLE 44 -#endif - -#include - -/* - * To avoid including windows.h we define only those things that we - * actually need from it. - */ -#if !defined(PTW32_INCLUDE_WINDOWS_H) -#if !defined(HANDLE) -# define PTW32__HANDLE_DEF -# define HANDLE void * -#endif -#if !defined(DWORD) -# define PTW32__DWORD_DEF -# define DWORD unsigned long -#endif -#endif - -#if !defined(HAVE_STRUCT_TIMESPEC) -#define HAVE_STRUCT_TIMESPEC -#if !defined(_TIMESPEC_DEFINED) -#define _TIMESPEC_DEFINED -struct timespec { - time_t tv_sec; - long tv_nsec; -}; -#endif /* _TIMESPEC_DEFINED */ -#endif /* HAVE_STRUCT_TIMESPEC */ - -#if !defined(SIG_BLOCK) -#define SIG_BLOCK 0 -#endif /* SIG_BLOCK */ - -#if !defined(SIG_UNBLOCK) -#define SIG_UNBLOCK 1 -#endif /* SIG_UNBLOCK */ - -#if !defined(SIG_SETMASK) -#define SIG_SETMASK 2 -#endif /* SIG_SETMASK */ - -#if defined(__cplusplus) -extern "C" -{ -#endif /* __cplusplus */ - -/* - * ------------------------------------------------------------- - * - * POSIX 1003.1-2001 Options - * ========================= - * - * Options are normally set in , which is not provided - * with pthreads-win32. - * - * For conformance with the Single Unix Specification (version 3), all of the - * options below are defined, and have a value of either -1 (not supported) - * or 200112L (supported). - * - * These options can neither be left undefined nor have a value of 0, because - * either indicates that sysconf(), which is not implemented, may be used at - * runtime to check the status of the option. - * - * _POSIX_THREADS (== 200112L) - * If == 200112L, you can use threads - * - * _POSIX_THREAD_ATTR_STACKSIZE (== 200112L) - * If == 200112L, you can control the size of a thread's - * stack - * pthread_attr_getstacksize - * pthread_attr_setstacksize - * - * _POSIX_THREAD_ATTR_STACKADDR (== -1) - * If == 200112L, you can allocate and control a thread's - * stack. If not supported, the following functions - * will return ENOSYS, indicating they are not - * supported: - * pthread_attr_getstackaddr - * pthread_attr_setstackaddr - * - * _POSIX_THREAD_PRIORITY_SCHEDULING (== -1) - * If == 200112L, you can use realtime scheduling. - * This option indicates that the behaviour of some - * implemented functions conforms to the additional TPS - * requirements in the standard. E.g. rwlocks favour - * writers over readers when threads have equal priority. - * - * _POSIX_THREAD_PRIO_INHERIT (== -1) - * If == 200112L, you can create priority inheritance - * mutexes. - * pthread_mutexattr_getprotocol + - * pthread_mutexattr_setprotocol + - * - * _POSIX_THREAD_PRIO_PROTECT (== -1) - * If == 200112L, you can create priority ceiling mutexes - * Indicates the availability of: - * pthread_mutex_getprioceiling - * pthread_mutex_setprioceiling - * pthread_mutexattr_getprioceiling - * pthread_mutexattr_getprotocol + - * pthread_mutexattr_setprioceiling - * pthread_mutexattr_setprotocol + - * - * _POSIX_THREAD_PROCESS_SHARED (== -1) - * If set, you can create mutexes and condition - * variables that can be shared with another - * process.If set, indicates the availability - * of: - * pthread_mutexattr_getpshared - * pthread_mutexattr_setpshared - * pthread_condattr_getpshared - * pthread_condattr_setpshared - * - * _POSIX_THREAD_SAFE_FUNCTIONS (== 200112L) - * If == 200112L you can use the special *_r library - * functions that provide thread-safe behaviour - * - * _POSIX_READER_WRITER_LOCKS (== 200112L) - * If == 200112L, you can use read/write locks - * - * _POSIX_SPIN_LOCKS (== 200112L) - * If == 200112L, you can use spin locks - * - * _POSIX_BARRIERS (== 200112L) - * If == 200112L, you can use barriers - * - * + These functions provide both 'inherit' and/or - * 'protect' protocol, based upon these macro - * settings. - * - * ------------------------------------------------------------- - */ - -/* - * POSIX Options - */ -#undef _POSIX_THREADS -#define _POSIX_THREADS 200809L - -#undef _POSIX_READER_WRITER_LOCKS -#define _POSIX_READER_WRITER_LOCKS 200809L - -#undef _POSIX_SPIN_LOCKS -#define _POSIX_SPIN_LOCKS 200809L - -#undef _POSIX_BARRIERS -#define _POSIX_BARRIERS 200809L - -#undef _POSIX_THREAD_SAFE_FUNCTIONS -#define _POSIX_THREAD_SAFE_FUNCTIONS 200809L - -#undef _POSIX_THREAD_ATTR_STACKSIZE -#define _POSIX_THREAD_ATTR_STACKSIZE 200809L - -/* - * The following options are not supported - */ -#undef _POSIX_THREAD_ATTR_STACKADDR -#define _POSIX_THREAD_ATTR_STACKADDR -1 - -#undef _POSIX_THREAD_PRIO_INHERIT -#define _POSIX_THREAD_PRIO_INHERIT -1 - -#undef _POSIX_THREAD_PRIO_PROTECT -#define _POSIX_THREAD_PRIO_PROTECT -1 - -/* TPS is not fully supported. */ -#undef _POSIX_THREAD_PRIORITY_SCHEDULING -#define _POSIX_THREAD_PRIORITY_SCHEDULING -1 - -#undef _POSIX_THREAD_PROCESS_SHARED -#define _POSIX_THREAD_PROCESS_SHARED -1 - - -/* - * POSIX 1003.1-2001 Limits - * =========================== - * - * These limits are normally set in , which is not provided with - * pthreads-win32. - * - * PTHREAD_DESTRUCTOR_ITERATIONS - * Maximum number of attempts to destroy - * a thread's thread-specific data on - * termination (must be at least 4) - * - * PTHREAD_KEYS_MAX - * Maximum number of thread-specific data keys - * available per process (must be at least 128) - * - * PTHREAD_STACK_MIN - * Minimum supported stack size for a thread - * - * PTHREAD_THREADS_MAX - * Maximum number of threads supported per - * process (must be at least 64). - * - * SEM_NSEMS_MAX - * The maximum number of semaphores a process can have. - * (must be at least 256) - * - * SEM_VALUE_MAX - * The maximum value a semaphore can have. - * (must be at least 32767) - * - */ -#undef _POSIX_THREAD_DESTRUCTOR_ITERATIONS -#define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 - -#undef PTHREAD_DESTRUCTOR_ITERATIONS -#define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS - -#undef _POSIX_THREAD_KEYS_MAX -#define _POSIX_THREAD_KEYS_MAX 128 - -#undef PTHREAD_KEYS_MAX -#define PTHREAD_KEYS_MAX _POSIX_THREAD_KEYS_MAX - -#undef PTHREAD_STACK_MIN -#define PTHREAD_STACK_MIN 0 - -#undef _POSIX_THREAD_THREADS_MAX -#define _POSIX_THREAD_THREADS_MAX 64 - - /* Arbitrary value */ -#undef PTHREAD_THREADS_MAX -#define PTHREAD_THREADS_MAX 2019 - -#undef _POSIX_SEM_NSEMS_MAX -#define _POSIX_SEM_NSEMS_MAX 256 - - /* Arbitrary value */ -#undef SEM_NSEMS_MAX -#define SEM_NSEMS_MAX 1024 - -#undef _POSIX_SEM_VALUE_MAX -#define _POSIX_SEM_VALUE_MAX 32767 - -#undef SEM_VALUE_MAX -#define SEM_VALUE_MAX INT_MAX - - -#if defined(__GNUC__) && !defined(__declspec) -# error Please upgrade your GNU compiler to one that supports __declspec. -#endif - -/* - * When building the library, you should define PTW32_BUILD so that - * the variables/functions are exported correctly. When using the library, - * do NOT define PTW32_BUILD, and then the variables/functions will - * be imported correctly. - */ -#if !defined(PTW32_STATIC_LIB) -# if defined(PTW32_BUILD) -# define PTW32_DLLPORT __declspec (dllexport) -# else -# define PTW32_DLLPORT __declspec (dllimport) -# endif -#else -# define PTW32_DLLPORT -#endif - -/* - * The Open Watcom C/C++ compiler uses a non-standard calling convention - * that passes function args in registers unless __cdecl is explicitly specified - * in exposed function prototypes. - * - * We force all calls to cdecl even though this could slow Watcom code down - * slightly. If you know that the Watcom compiler will be used to build both - * the DLL and application, then you can probably define this as a null string. - * Remember that pthread.h (this file) is used for both the DLL and application builds. - */ -#define PTW32_CDECL __cdecl - -#if defined(_UWIN) && PTW32_LEVEL >= PTW32_LEVEL_MAX -# include -#else -/* - * Generic handle type - intended to extend uniqueness beyond - * that available with a simple pointer. It should scale for either - * IA-32 or IA-64. - */ -typedef struct { - void * p; /* Pointer to actual object */ - unsigned int x; /* Extra information - reuse count etc */ -} ptw32_handle_t; - -typedef ptw32_handle_t pthread_t; -typedef struct pthread_attr_t_ * pthread_attr_t; -typedef struct pthread_once_t_ pthread_once_t; -typedef struct pthread_key_t_ * pthread_key_t; -typedef struct pthread_mutex_t_ * pthread_mutex_t; -typedef struct pthread_mutexattr_t_ * pthread_mutexattr_t; -typedef struct pthread_cond_t_ * pthread_cond_t; -typedef struct pthread_condattr_t_ * pthread_condattr_t; -#endif -typedef struct pthread_rwlock_t_ * pthread_rwlock_t; -typedef struct pthread_rwlockattr_t_ * pthread_rwlockattr_t; -typedef struct pthread_spinlock_t_ * pthread_spinlock_t; -typedef struct pthread_barrier_t_ * pthread_barrier_t; -typedef struct pthread_barrierattr_t_ * pthread_barrierattr_t; - -/* - * ==================== - * ==================== - * POSIX Threads - * ==================== - * ==================== - */ - -enum { -/* - * pthread_attr_{get,set}detachstate - */ - PTHREAD_CREATE_JOINABLE = 0, /* Default */ - PTHREAD_CREATE_DETACHED = 1, - -/* - * pthread_attr_{get,set}inheritsched - */ - PTHREAD_INHERIT_SCHED = 0, - PTHREAD_EXPLICIT_SCHED = 1, /* Default */ - -/* - * pthread_{get,set}scope - */ - PTHREAD_SCOPE_PROCESS = 0, - PTHREAD_SCOPE_SYSTEM = 1, /* Default */ - -/* - * pthread_setcancelstate paramters - */ - PTHREAD_CANCEL_ENABLE = 0, /* Default */ - PTHREAD_CANCEL_DISABLE = 1, - -/* - * pthread_setcanceltype parameters - */ - PTHREAD_CANCEL_ASYNCHRONOUS = 0, - PTHREAD_CANCEL_DEFERRED = 1, /* Default */ - -/* - * pthread_mutexattr_{get,set}pshared - * pthread_condattr_{get,set}pshared - */ - PTHREAD_PROCESS_PRIVATE = 0, - PTHREAD_PROCESS_SHARED = 1, - -/* - * pthread_mutexattr_{get,set}robust - */ - PTHREAD_MUTEX_STALLED = 0, /* Default */ - PTHREAD_MUTEX_ROBUST = 1, - -/* - * pthread_barrier_wait - */ - PTHREAD_BARRIER_SERIAL_THREAD = -1 -}; - -/* - * ==================== - * ==================== - * cancellation - * ==================== - * ==================== - */ -#define PTHREAD_CANCELED ((void *)(size_t) -1) - - -/* - * ==================== - * ==================== - * Once Key - * ==================== - * ==================== - */ -#define PTHREAD_ONCE_INIT { PTW32_FALSE, 0, 0, 0} - -struct pthread_once_t_ -{ - int done; /* indicates if user function has been executed */ - void * lock; - int reserved1; - int reserved2; -}; - - -/* - * ==================== - * ==================== - * Object initialisers - * ==================== - * ==================== - */ -#define PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -1) -#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -2) -#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER ((pthread_mutex_t)(size_t) -3) - -/* - * Compatibility with LinuxThreads - */ -#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER -#define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP PTHREAD_ERRORCHECK_MUTEX_INITIALIZER - -#define PTHREAD_COND_INITIALIZER ((pthread_cond_t)(size_t) -1) - -#define PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t)(size_t) -1) - -#define PTHREAD_SPINLOCK_INITIALIZER ((pthread_spinlock_t)(size_t) -1) - - -/* - * Mutex types. - */ -enum -{ - /* Compatibility with LinuxThreads */ - PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_RECURSIVE_NP, - PTHREAD_MUTEX_ERRORCHECK_NP, - PTHREAD_MUTEX_TIMED_NP = PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_ADAPTIVE_NP = PTHREAD_MUTEX_FAST_NP, - /* For compatibility with POSIX */ - PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_FAST_NP, - PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, - PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, - PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL -}; - - -typedef struct ptw32_cleanup_t ptw32_cleanup_t; - -#if defined(_MSC_VER) -/* Disable MSVC 'anachronism used' warning */ -#pragma warning( disable : 4229 ) -#endif - -typedef void (* PTW32_CDECL ptw32_cleanup_callback_t)(void *); - -#if defined(_MSC_VER) -#pragma warning( default : 4229 ) -#endif - -struct ptw32_cleanup_t -{ - ptw32_cleanup_callback_t routine; - void *arg; - struct ptw32_cleanup_t *prev; -}; - -#if defined(__CLEANUP_SEH) - /* - * WIN32 SEH version of cancel cleanup. - */ - -#define pthread_cleanup_push( _rout, _arg ) \ - { \ - ptw32_cleanup_t _cleanup; \ - \ - _cleanup.routine = (ptw32_cleanup_callback_t)(_rout); \ - _cleanup.arg = (_arg); \ - __try \ - { \ - -#define pthread_cleanup_pop( _execute ) \ - } \ - __finally \ - { \ - if( _execute || AbnormalTermination()) \ - { \ - (*(_cleanup.routine))( _cleanup.arg ); \ - } \ - } \ - } - -#else /* __CLEANUP_SEH */ - -#if defined(__CLEANUP_C) - - /* - * C implementation of PThreads cancel cleanup - */ - -#define pthread_cleanup_push( _rout, _arg ) \ - { \ - ptw32_cleanup_t _cleanup; \ - \ - ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t) (_rout), (_arg) ); \ - -#define pthread_cleanup_pop( _execute ) \ - (void) ptw32_pop_cleanup( _execute ); \ - } - -#else /* __CLEANUP_C */ - -#if defined(__CLEANUP_CXX) - - /* - * C++ version of cancel cleanup. - * - John E. Bossom. - */ - - class PThreadCleanup { - /* - * PThreadCleanup - * - * Purpose - * This class is a C++ helper class that is - * used to implement pthread_cleanup_push/ - * pthread_cleanup_pop. - * The destructor of this class automatically - * pops the pushed cleanup routine regardless - * of how the code exits the scope - * (i.e. such as by an exception) - */ - ptw32_cleanup_callback_t cleanUpRout; - void * obj; - int executeIt; - - public: - PThreadCleanup() : - cleanUpRout( 0 ), - obj( 0 ), - executeIt( 0 ) - /* - * No cleanup performed - */ - { - } - - PThreadCleanup( - ptw32_cleanup_callback_t routine, - void * arg ) : - cleanUpRout( routine ), - obj( arg ), - executeIt( 1 ) - /* - * Registers a cleanup routine for 'arg' - */ - { - } - - ~PThreadCleanup() - { - if ( executeIt && ((void *) cleanUpRout != (void *) 0) ) - { - (void) (*cleanUpRout)( obj ); - } - } - - void execute( int exec ) - { - executeIt = exec; - } - }; - - /* - * C++ implementation of PThreads cancel cleanup; - * This implementation takes advantage of a helper - * class who's destructor automatically calls the - * cleanup routine if we exit our scope weirdly - */ -#define pthread_cleanup_push( _rout, _arg ) \ - { \ - PThreadCleanup cleanup((ptw32_cleanup_callback_t)(_rout), \ - (void *) (_arg) ); - -#define pthread_cleanup_pop( _execute ) \ - cleanup.execute( _execute ); \ - } - -#else - -#error ERROR [__FILE__, line __LINE__]: Cleanup type undefined. - -#endif /* __CLEANUP_CXX */ - -#endif /* __CLEANUP_C */ - -#endif /* __CLEANUP_SEH */ - -/* - * =============== - * =============== - * Methods - * =============== - * =============== - */ - -/* - * PThread Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_attr_init (pthread_attr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_destroy (pthread_attr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getdetachstate (const pthread_attr_t * attr, - int *detachstate); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstackaddr (const pthread_attr_t * attr, - void **stackaddr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getstacksize (const pthread_attr_t * attr, - size_t * stacksize); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setdetachstate (pthread_attr_t * attr, - int detachstate); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstackaddr (pthread_attr_t * attr, - void *stackaddr); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setstacksize (pthread_attr_t * attr, - size_t stacksize); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedparam (const pthread_attr_t *attr, - struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedparam (pthread_attr_t *attr, - const struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setschedpolicy (pthread_attr_t *, - int); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getschedpolicy (const pthread_attr_t *, - int *); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setinheritsched(pthread_attr_t * attr, - int inheritsched); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getinheritsched(const pthread_attr_t * attr, - int * inheritsched); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_setscope (pthread_attr_t *, - int); - -PTW32_DLLPORT int PTW32_CDECL pthread_attr_getscope (const pthread_attr_t *, - int *); - -/* - * PThread Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_create (pthread_t * tid, - const pthread_attr_t * attr, - void *(PTW32_CDECL *start) (void *), - void *arg); - -PTW32_DLLPORT int PTW32_CDECL pthread_detach (pthread_t tid); - -PTW32_DLLPORT int PTW32_CDECL pthread_equal (pthread_t t1, - pthread_t t2); - -PTW32_DLLPORT void PTW32_CDECL pthread_exit (void *value_ptr); - -PTW32_DLLPORT int PTW32_CDECL pthread_join (pthread_t thread, - void **value_ptr); - -PTW32_DLLPORT pthread_t PTW32_CDECL pthread_self (void); - -PTW32_DLLPORT int PTW32_CDECL pthread_cancel (pthread_t thread); - -PTW32_DLLPORT int PTW32_CDECL pthread_setcancelstate (int state, - int *oldstate); - -PTW32_DLLPORT int PTW32_CDECL pthread_setcanceltype (int type, - int *oldtype); - -PTW32_DLLPORT void PTW32_CDECL pthread_testcancel (void); - -PTW32_DLLPORT int PTW32_CDECL pthread_once (pthread_once_t * once_control, - void (PTW32_CDECL *init_routine) (void)); - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX -PTW32_DLLPORT ptw32_cleanup_t * PTW32_CDECL ptw32_pop_cleanup (int execute); - -PTW32_DLLPORT void PTW32_CDECL ptw32_push_cleanup (ptw32_cleanup_t * cleanup, - ptw32_cleanup_callback_t routine, - void *arg); -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -/* - * Thread Specific Data Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_key_create (pthread_key_t * key, - void (PTW32_CDECL *destructor) (void *)); - -PTW32_DLLPORT int PTW32_CDECL pthread_key_delete (pthread_key_t key); - -PTW32_DLLPORT int PTW32_CDECL pthread_setspecific (pthread_key_t key, - const void *value); - -PTW32_DLLPORT void * PTW32_CDECL pthread_getspecific (pthread_key_t key); - - -/* - * Mutex Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_init (pthread_mutexattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_destroy (pthread_mutexattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getpshared (const pthread_mutexattr_t - * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setpshared (pthread_mutexattr_t * attr, - int pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_settype (pthread_mutexattr_t * attr, int kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setrobust( - pthread_mutexattr_t *attr, - int robust); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getrobust( - const pthread_mutexattr_t * attr, - int * robust); - -/* - * Barrier Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_init (pthread_barrierattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_destroy (pthread_barrierattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_getpshared (const pthread_barrierattr_t - * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrierattr_setpshared (pthread_barrierattr_t * attr, - int pshared); - -/* - * Mutex Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_init (pthread_mutex_t * mutex, - const pthread_mutexattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_destroy (pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_lock (pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_timedlock(pthread_mutex_t * mutex, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_trylock (pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_unlock (pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_mutex_consistent (pthread_mutex_t * mutex); - -/* - * Spinlock Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_spin_init (pthread_spinlock_t * lock, int pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_destroy (pthread_spinlock_t * lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_lock (pthread_spinlock_t * lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_trylock (pthread_spinlock_t * lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_spin_unlock (pthread_spinlock_t * lock); - -/* - * Barrier Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_init (pthread_barrier_t * barrier, - const pthread_barrierattr_t * attr, - unsigned int count); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_destroy (pthread_barrier_t * barrier); - -PTW32_DLLPORT int PTW32_CDECL pthread_barrier_wait (pthread_barrier_t * barrier); - -/* - * Condition Variable Attribute Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_init (pthread_condattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_destroy (pthread_condattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_getpshared (const pthread_condattr_t * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_condattr_setpshared (pthread_condattr_t * attr, - int pshared); - -/* - * Condition Variable Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_cond_init (pthread_cond_t * cond, - const pthread_condattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_destroy (pthread_cond_t * cond); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_wait (pthread_cond_t * cond, - pthread_mutex_t * mutex); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_timedwait (pthread_cond_t * cond, - pthread_mutex_t * mutex, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_signal (pthread_cond_t * cond); - -PTW32_DLLPORT int PTW32_CDECL pthread_cond_broadcast (pthread_cond_t * cond); - -/* - * Scheduling - */ -PTW32_DLLPORT int PTW32_CDECL pthread_setschedparam (pthread_t thread, - int policy, - const struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_getschedparam (pthread_t thread, - int *policy, - struct sched_param *param); - -PTW32_DLLPORT int PTW32_CDECL pthread_setconcurrency (int); - -PTW32_DLLPORT int PTW32_CDECL pthread_getconcurrency (void); - -/* - * Read-Write Lock Functions - */ -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_init(pthread_rwlock_t *lock, - const pthread_rwlockattr_t *attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_destroy(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_tryrdlock(pthread_rwlock_t *); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_trywrlock(pthread_rwlock_t *); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_rdlock(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedrdlock(pthread_rwlock_t *lock, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_wrlock(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_timedwrlock(pthread_rwlock_t *lock, - const struct timespec *abstime); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlock_unlock(pthread_rwlock_t *lock); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_init (pthread_rwlockattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_destroy (pthread_rwlockattr_t * attr); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_getpshared (const pthread_rwlockattr_t * attr, - int *pshared); - -PTW32_DLLPORT int PTW32_CDECL pthread_rwlockattr_setpshared (pthread_rwlockattr_t * attr, - int pshared); - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 - -/* - * Signal Functions. Should be defined in but MSVC and MinGW32 - * already have signal.h that don't define these. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_kill(pthread_t thread, int sig); - -/* - * Non-portable functions - */ - -/* - * Compatibility with Linux. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_setkind_np(pthread_mutexattr_t * attr, - int kind); -PTW32_DLLPORT int PTW32_CDECL pthread_mutexattr_getkind_np(pthread_mutexattr_t * attr, - int *kind); -PTW32_DLLPORT int PTW32_CDECL pthread_timedjoin_np(pthread_t thread, - void **value_ptr, - const struct timespec *abstime); - -/* - * Possibly supported by other POSIX threads implementations - */ -PTW32_DLLPORT int PTW32_CDECL pthread_delay_np (struct timespec * interval); -PTW32_DLLPORT int PTW32_CDECL pthread_num_processors_np(void); -PTW32_DLLPORT unsigned __int64 PTW32_CDECL pthread_getunique_np(pthread_t thread); - -/* - * Useful if an application wants to statically link - * the lib rather than load the DLL at run-time. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_attach_np(void); -PTW32_DLLPORT int PTW32_CDECL pthread_win32_process_detach_np(void); -PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_attach_np(void); -PTW32_DLLPORT int PTW32_CDECL pthread_win32_thread_detach_np(void); - -/* - * Features that are auto-detected at load/run time. - */ -PTW32_DLLPORT int PTW32_CDECL pthread_win32_test_features_np(int); -enum ptw32_features { - PTW32_SYSTEM_INTERLOCKED_COMPARE_EXCHANGE = 0x0001, /* System provides it. */ - PTW32_ALERTABLE_ASYNC_CANCEL = 0x0002 /* Can cancel blocked threads. */ -}; - -/* - * Register a system time change with the library. - * Causes the library to perform various functions - * in response to the change. Should be called whenever - * the application's top level window receives a - * WM_TIMECHANGE message. It can be passed directly to - * pthread_create() as a new thread if desired. - */ -PTW32_DLLPORT void * PTW32_CDECL pthread_timechange_handler_np(void *); - -#endif /*PTW32_LEVEL >= PTW32_LEVEL_MAX - 1 */ - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX - -/* - * Returns the Win32 HANDLE for the POSIX thread. - */ -PTW32_DLLPORT HANDLE PTW32_CDECL pthread_getw32threadhandle_np(pthread_t thread); -/* - * Returns the win32 thread ID for POSIX thread. - */ -PTW32_DLLPORT DWORD PTW32_CDECL pthread_getw32threadid_np (pthread_t thread); - - -/* - * Protected Methods - * - * This function blocks until the given WIN32 handle - * is signaled or pthread_cancel had been called. - * This function allows the caller to hook into the - * PThreads cancel mechanism. It is implemented using - * - * WaitForMultipleObjects - * - * on 'waitHandle' and a manually reset WIN32 Event - * used to implement pthread_cancel. The 'timeout' - * argument to TimedWait is simply passed to - * WaitForMultipleObjects. - */ -PTW32_DLLPORT int PTW32_CDECL pthreadCancelableWait (HANDLE waitHandle); -PTW32_DLLPORT int PTW32_CDECL pthreadCancelableTimedWait (HANDLE waitHandle, - DWORD timeout); - -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -/* - * Thread-Safe C Runtime Library Mappings. - */ -#if !defined(_UWIN) -# if defined(NEED_ERRNO) - PTW32_DLLPORT int * PTW32_CDECL _errno( void ); -# else -# if !defined(errno) -# if (defined(_MT) || defined(_DLL)) - __declspec(dllimport) extern int * __cdecl _errno(void); -# define errno (*_errno()) -# endif -# endif -# endif -#endif - -/* - * Some compiler environments don't define some things. - */ -#if defined(__BORLANDC__) -# define _ftime ftime -# define _timeb timeb -#endif - -#if defined(__cplusplus) - -/* - * Internal exceptions - */ -class ptw32_exception {}; -class ptw32_exception_cancel : public ptw32_exception {}; -class ptw32_exception_exit : public ptw32_exception {}; - -#endif - -#if PTW32_LEVEL >= PTW32_LEVEL_MAX - -/* FIXME: This is only required if the library was built using SEH */ -/* - * Get internal SEH tag - */ -PTW32_DLLPORT DWORD PTW32_CDECL ptw32_get_exception_services_code(void); - -#endif /* PTW32_LEVEL >= PTW32_LEVEL_MAX */ - -#if !defined(PTW32_BUILD) - -#if defined(__CLEANUP_SEH) - -/* - * Redefine the SEH __except keyword to ensure that applications - * propagate our internal exceptions up to the library's internal handlers. - */ -#define __except( E ) \ - __except( ( GetExceptionCode() == ptw32_get_exception_services_code() ) \ - ? EXCEPTION_CONTINUE_SEARCH : ( E ) ) - -#endif /* __CLEANUP_SEH */ - -#if defined(__CLEANUP_CXX) - -/* - * Redefine the C++ catch keyword to ensure that applications - * propagate our internal exceptions up to the library's internal handlers. - */ -#if defined(_MSC_VER) - /* - * WARNING: Replace any 'catch( ... )' with 'PtW32CatchAll' - * if you want Pthread-Win32 cancellation and pthread_exit to work. - */ - -#if !defined(PtW32NoCatchWarn) - -#pragma message("Specify \"/DPtW32NoCatchWarn\" compiler flag to skip this message.") -#pragma message("------------------------------------------------------------------") -#pragma message("When compiling applications with MSVC++ and C++ exception handling:") -#pragma message(" Replace any 'catch( ... )' in routines called from POSIX threads") -#pragma message(" with 'PtW32CatchAll' or 'CATCHALL' if you want POSIX thread") -#pragma message(" cancellation and pthread_exit to work. For example:") -#pragma message("") -#pragma message(" #if defined(PtW32CatchAll)") -#pragma message(" PtW32CatchAll") -#pragma message(" #else") -#pragma message(" catch(...)") -#pragma message(" #endif") -#pragma message(" {") -#pragma message(" /* Catchall block processing */") -#pragma message(" }") -#pragma message("------------------------------------------------------------------") - -#endif - -#define PtW32CatchAll \ - catch( ptw32_exception & ) { throw; } \ - catch( ... ) - -#else /* _MSC_VER */ - -#define catch( E ) \ - catch( ptw32_exception & ) { throw; } \ - catch( E ) - -#endif /* _MSC_VER */ - -#endif /* __CLEANUP_CXX */ - -#endif /* ! PTW32_BUILD */ - -#if defined(__cplusplus) -} /* End of extern "C" */ -#endif /* __cplusplus */ - -#if defined(PTW32__HANDLE_DEF) -# undef HANDLE -#endif -#if defined(PTW32__DWORD_DEF) -# undef DWORD -#endif - -#undef PTW32_LEVEL -#undef PTW32_LEVEL_MAX - -#endif /* ! RC_INVOKED */ - -#endif /* PTHREAD_H */ diff --git a/libraries/shared/external/sched.h b/libraries/shared/external/sched.h deleted file mode 100644 index d43ff8dcb2..0000000000 --- a/libraries/shared/external/sched.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Module: sched.h - * - * Purpose: - * Provides an implementation of POSIX realtime extensions - * as defined in - * - * POSIX 1003.1b-1993 (POSIX.1b) - * - * -------------------------------------------------------------------------- - * - * Pthreads-win32 - POSIX Threads Library for Win32 - * Copyright(C) 1998 John E. Bossom - * Copyright(C) 1999,2005 Pthreads-win32 contributors - * - * Contact Email: rpj@callisto.canberra.edu.au - * - * The current list of contributors is contained - * in the file CONTRIBUTORS included with the source - * code distribution. The list can also be seen at the - * following World Wide Web location: - * http://sources.redhat.com/pthreads-win32/contributors.html - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library in the file COPYING.LIB; - * if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ -#if !defined(_SCHED_H) -#define _SCHED_H - -#undef PTW32_SCHED_LEVEL - -#if defined(_POSIX_SOURCE) -#define PTW32_SCHED_LEVEL 0 -/* Early POSIX */ -#endif - -#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309 -#undef PTW32_SCHED_LEVEL -#define PTW32_SCHED_LEVEL 1 -/* Include 1b, 1c and 1d */ -#endif - -#if defined(INCLUDE_NP) -#undef PTW32_SCHED_LEVEL -#define PTW32_SCHED_LEVEL 2 -/* Include Non-Portable extensions */ -#endif - -#define PTW32_SCHED_LEVEL_MAX 3 - -#if ( defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112 ) || !defined(PTW32_SCHED_LEVEL) -#define PTW32_SCHED_LEVEL PTW32_SCHED_LEVEL_MAX -/* Include everything */ -#endif - - -#if defined(__GNUC__) && !defined(__declspec) -# error Please upgrade your GNU compiler to one that supports __declspec. -#endif - -/* - * When building the library, you should define PTW32_BUILD so that - * the variables/functions are exported correctly. When using the library, - * do NOT define PTW32_BUILD, and then the variables/functions will - * be imported correctly. - */ -#if !defined(PTW32_STATIC_LIB) -# if defined(PTW32_BUILD) -# define PTW32_DLLPORT __declspec (dllexport) -# else -# define PTW32_DLLPORT __declspec (dllimport) -# endif -#else -# define PTW32_DLLPORT -#endif - -/* - * This is a duplicate of what is in the autoconf config.h, - * which is only used when building the pthread-win32 libraries. - */ - -#if !defined(PTW32_CONFIG_H) -# if defined(WINCE) -# define NEED_ERRNO -# define NEED_SEM -# endif -# if defined(__MINGW64__) -# define HAVE_STRUCT_TIMESPEC -# define HAVE_MODE_T -# elif defined(_UWIN) || defined(__MINGW32__) -# define HAVE_MODE_T -# endif -#endif - -/* - * - */ - -#if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX -#if defined(NEED_ERRNO) -#include "need_errno.h" -#else -#include -#endif -#endif /* PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX */ - -#if (defined(__MINGW64__) || defined(__MINGW32__)) || defined(_UWIN) -# if PTW32_SCHED_LEVEL >= PTW32_SCHED_LEVEL_MAX -/* For pid_t */ -# include -/* Required by Unix 98 */ -# include -# else - typedef int pid_t; -# endif -#else - /* [i_a] fix for using pthread_win32 with mongoose code, which #define's its own pid_t akin to typedef HANDLE pid_t; */ - #undef pid_t -# if defined(_MSC_VER) - typedef void *pid_t; -# else - typedef int pid_t; -# endif -#endif - -/* Thread scheduling policies */ - -enum { - SCHED_OTHER = 0, - SCHED_FIFO, - SCHED_RR, - SCHED_MIN = SCHED_OTHER, - SCHED_MAX = SCHED_RR -}; - -struct sched_param { - int sched_priority; -}; - -#if defined(__cplusplus) -extern "C" -{ -#endif /* __cplusplus */ - -PTW32_DLLPORT int __cdecl sched_yield (void); - -PTW32_DLLPORT int __cdecl sched_get_priority_min (int policy); - -PTW32_DLLPORT int __cdecl sched_get_priority_max (int policy); - -PTW32_DLLPORT int __cdecl sched_setscheduler (pid_t pid, int policy); - -PTW32_DLLPORT int __cdecl sched_getscheduler (pid_t pid); - -/* - * Note that this macro returns ENOTSUP rather than - * ENOSYS as might be expected. However, returning ENOSYS - * should mean that sched_get_priority_{min,max} are - * not implemented as well as sched_rr_get_interval. - * This is not the case, since we just don't support - * round-robin scheduling. Therefore I have chosen to - * return the same value as sched_setscheduler when - * SCHED_RR is passed to it. - */ -#define sched_rr_get_interval(_pid, _interval) \ - ( errno = ENOTSUP, (int) -1 ) - - -#if defined(__cplusplus) -} /* End of extern "C" */ -#endif /* __cplusplus */ - -#undef PTW32_SCHED_LEVEL -#undef PTW32_SCHED_LEVEL_MAX - -#endif /* !_SCHED_H */ - From b5c8a4d2c635d4788b7c7fc6597293861fe66849 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 15:47:57 -0700 Subject: [PATCH 05/43] fix requirement of networking in audio library --- cmake/macros/LinkHifiLibrary.cmake | 9 ++++++++- libraries/animation/CMakeLists.txt | 9 ++++++--- libraries/audio/CMakeLists.txt | 7 +++++++ libraries/embedded-webserver/CMakeLists.txt | 8 ++++---- libraries/fbx/CMakeLists.txt | 6 +++++- libraries/metavoxels/CMakeLists.txt | 10 +++++++--- libraries/models/CMakeLists.txt | 11 +---------- libraries/networking/CMakeLists.txt | 13 ++++--------- libraries/shared/CMakeLists.txt | 10 +++++----- 9 files changed, 47 insertions(+), 36 deletions(-) diff --git a/cmake/macros/LinkHifiLibrary.cmake b/cmake/macros/LinkHifiLibrary.cmake index afb1f1febd..227ddf066a 100644 --- a/cmake/macros/LinkHifiLibrary.cmake +++ b/cmake/macros/LinkHifiLibrary.cmake @@ -17,5 +17,12 @@ macro(LINK_HIFI_LIBRARY LIBRARY TARGET ROOT_DIR) add_dependencies(${TARGET} ${LIBRARY}) - target_link_libraries(${TARGET} ${LIBRARY} ${SUB_DEPENDENCY_LIBRARIES}) + get_target_property(LINKED_TARGET_DEPENDENCY_LIBRARIES ${LIBRARY} DEPENDENCY_LIBRARIES) + + if (LINKED_TARGET_DEPENDENCY_LIBRARIES) + target_link_libraries(${TARGET} ${LIBRARY} ${LINKED_TARGET_DEPENDENCY_LIBRARIES}) + else () + target_link_libraries(${TARGET} ${LIBRARY}) + endif () + endmacro(LINK_HIFI_LIBRARY _library _target _root_dir) \ No newline at end of file diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index be6ed47898..20f4a59181 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -6,8 +6,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME animation) -find_package(Qt5 COMPONENTS Script) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -15,7 +13,12 @@ include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -target_link_libraries(${TARGET_NAME} Qt5::Script) +find_package(Qt5Script) + +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Script) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index 2ad8a4b0bc..69cc61ca6d 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -20,6 +20,13 @@ include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") +find_package(Qt5Network) + +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Network) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) + # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/libraries/embedded-webserver/CMakeLists.txt b/libraries/embedded-webserver/CMakeLists.txt index f1681cdd12..eb28cae1b3 100644 --- a/libraries/embedded-webserver/CMakeLists.txt +++ b/libraries/embedded-webserver/CMakeLists.txt @@ -11,7 +11,7 @@ setup_hifi_library(${TARGET_NAME}) find_package(Qt5Network REQUIRED) -# bubble up the libraries we are dependent on and link them to ourselves -set(REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network) -set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) -target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) \ No newline at end of file +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Network) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index 45d1051dc6..a125de1320 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -22,7 +22,11 @@ link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") find_package(ZLIB) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets) + +# bubble up the libraries we are dependent on and link them to ourselves +set(REQUIRED_DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}") +set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) +target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index c79631ce06..c419f664a0 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -6,8 +6,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME metavoxels) -find_package(Qt5 COMPONENTS Network Script Widgets) - include(${MACRO_DIR}/AutoMTC.cmake) auto_mtc(${TARGET_NAME} "${ROOT_DIR}") @@ -21,7 +19,13 @@ link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script) +find_package(Qt5Script) +find_package(Qt5Widgets) + +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Widgets) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index 8056d215da..142faee2b3 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -8,11 +8,8 @@ set(TARGET_NAME models) find_package(Qt5Widgets REQUIRED) -include(${MACRO_DIR}/AutoMTC.cmake) -auto_mtc(${TARGET_NAME} "${ROOT_DIR}") - include(${MACRO_DIR}/SetupHifiLibrary.cmake) -setup_hifi_library(${TARGET_NAME} "${AUTOMTC_SRC}") +setup_hifi_library(${TARGET_NAME}) include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") @@ -27,12 +24,6 @@ link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") # for streamable link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") -# link ZLIB -find_package(ZLIB) - -include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets) - # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 215d406133..2d47f7df9b 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -2,21 +2,16 @@ set(ROOT_DIR ../..) set(MACRO_DIR "${ROOT_DIR}/cmake/macros") set(TARGET_NAME networking) -project(${TARGET_NAME}) include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -# include GLM -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - find_package(Qt5Network) -# bubble up the libraries we are dependent on and link them to ourselves -set(REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network) -set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) -target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Network) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 067551ba31..5faedff6ed 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -14,16 +14,16 @@ include_glm(${TARGET_NAME} "${ROOT_DIR}") # link required libraries on UNIX if (APPLE) find_library(CoreServices CoreServices) - list(APPEND REQUIRED_DEPENDENCY_LIBRARIES ${CoreServices}) + set(DEPENDENCY_LIBRARIES ${CoreServices}) elseif (UNIX) find_package(Threads REQUIRED) - LIST(APPEND REQUIRED_DEPENDENCY_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") + set(DEPENDENCY_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") endif () find_package(Qt5Network) find_package(Qt5Widgets) # bubble up the libraries we are dependent on and link them to ourselves -list(APPEND REQUIRED_DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) -set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) -target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) \ No newline at end of file +list(APPEND DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file From 1059e9a6355b1d72f0d9020e4c0b5f681ea908a0 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 15:50:15 -0700 Subject: [PATCH 06/43] add back more required Qt modules --- libraries/avatars/CMakeLists.txt | 7 +++++++ libraries/fbx/CMakeLists.txt | 8 ++++---- libraries/metavoxels/CMakeLists.txt | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index feb1e68557..c7defaafe2 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -19,6 +19,13 @@ link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") +find_package(Qt5Network) + +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Network) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) + # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index a125de1320..ba51fe2e06 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -23,10 +23,10 @@ find_package(ZLIB) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -# bubble up the libraries we are dependent on and link them to ourselves -set(REQUIRED_DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}") -set(SUB_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} PARENT_SCOPE) -target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}") +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index c419f664a0..10feb55199 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -21,9 +21,10 @@ include_glm(${TARGET_NAME} "${ROOT_DIR}") find_package(Qt5Script) find_package(Qt5Widgets) +find_package(Qt5Network) # set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Widgets) +set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Widgets Qt5::Network) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) From 2bb37f2d64b313e701dd7d6817d7e6970dd1853a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 15:56:39 -0700 Subject: [PATCH 07/43] more Qt module dependencies sorted out for libraries --- libraries/animation/CMakeLists.txt | 3 ++- libraries/avatars/CMakeLists.txt | 5 +++-- libraries/models/CMakeLists.txt | 8 ++++++++ libraries/octree/CMakeLists.txt | 9 ++++----- libraries/particles/CMakeLists.txt | 8 ++++++++ 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 20f4a59181..1ed0275a72 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -14,9 +14,10 @@ link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") find_package(Qt5Script) +find_package(Qt5Network) # set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Script) +set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Network) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index c7defaafe2..2aae671146 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -20,10 +20,11 @@ link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") find_package(Qt5Network) +find_package(Qt5Script) # set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index 142faee2b3..0d7b3cf4fc 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -24,6 +24,14 @@ link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") # for streamable link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") +find_package(Qt5Network) +find_package(Qt5Script) + +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) + # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index 99da8d1bf2..d0beade108 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -21,12 +21,11 @@ find_package(ZLIB) find_package(OpenSSL REQUIRED) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") - -# bubble up the libraries we are dependent on -set(REQUIRED_DEPENDENCY_LIBRARIES ${REQUIRED_DEPENDENCY_LIBRARIES} - "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}" PARENT_SCOPE) -target_link_libraries(${TARGET_NAME} ${REQUIRED_DEPENDENCY_LIBRARIES}) +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}") +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index cecbdaaa21..ceac4324c0 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -19,6 +19,14 @@ link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") +find_package(Qt5Network) +find_package(Qt5Script) + +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) + # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) From 892e30c5e17e09f44a1a3514d75151250a760b57 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 16:13:29 -0700 Subject: [PATCH 08/43] get past assignment-client build after cmake auditing --- assignment-client/CMakeLists.txt | 14 +++++- interface/CMakeLists.txt | 52 ++++++++++----------- libraries/animation/CMakeLists.txt | 3 +- libraries/audio/CMakeLists.txt | 2 +- libraries/audio/src/AudioRingBuffer.cpp | 4 +- libraries/audio/src/AudioRingBuffer.h | 6 +-- libraries/avatars/CMakeLists.txt | 3 +- libraries/embedded-webserver/CMakeLists.txt | 2 +- libraries/metavoxels/CMakeLists.txt | 4 +- libraries/models/CMakeLists.txt | 3 +- libraries/networking/CMakeLists.txt | 2 +- libraries/particles/CMakeLists.txt | 5 +- libraries/script-engine/CMakeLists.txt | 11 ++--- libraries/shared/CMakeLists.txt | 5 +- 14 files changed, 57 insertions(+), 59 deletions(-) diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index a4e26899fb..3fb0f574a5 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -9,6 +9,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake include("${MACRO_DIR}/SetupHifiProject.cmake") setup_hifi_project(${TARGET_NAME} TRUE) +include(${MACRO_DIR}/IncludeGLM.cmake) +include_glm(${TARGET_NAME} "${ROOT_DIR}") + # link in the shared libraries include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") @@ -26,13 +29,20 @@ link_hifi_library(script-engine ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(embedded-webserver ${TARGET_NAME} "${ROOT_DIR}") if (UNIX) - target_link_libraries(${TARGET_NAME} ${CMAKE_DL_LIBS}) + list(APPEND DEPENDENCY_LIBRARIES ${CMAKE_DL_LIBS}) endif (UNIX) IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) + list(APPEND DEPENDENCY_LIBRARIES Winmm Ws2_32) ENDIF(WIN32) +find_package(Qt5 COMPONENTS Gui Network Script Widgets) + +# set a property indicating the libraries we are dependent on and link them to ourselves +list(APPEND DEPENDENCY_LIBRARIES Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) + # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 5c1bec0321..e624388408 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -52,7 +52,7 @@ foreach(SUBDIR avatar devices renderer ui starfield location scripting voxels pa set(INTERFACE_SRCS ${INTERFACE_SRCS} "${SUBDIR_SRCS}") endforeach(SUBDIR) -find_package(Qt5 COMPONENTS Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml UiTools) +# find_package(Qt5 COMPONENTS Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml UiTools) # grab the ui files in resources/ui file (GLOB_RECURSE QT_UI_FILES ui/*.ui) @@ -182,8 +182,6 @@ include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes" target_link_libraries( ${TARGET_NAME} "${ZLIB_LIBRARIES}" - Qt5::Core Qt5::Gui Qt5::Multimedia Qt5::Network Qt5::OpenGL - Qt5::Script Qt5::Svg Qt5::WebKit Qt5::WebKitWidgets Qt5::Xml Qt5::UiTools ) # assume we are using a Qt build without bearer management @@ -191,30 +189,30 @@ add_definitions(-DQT_NO_BEARERMANAGEMENT) if (APPLE) # link in required OS X frameworks and include the right GL headers - find_library(AppKit AppKit) - find_library(CoreAudio CoreAudio) - find_library(CoreServices CoreServices) - find_library(Carbon Carbon) - find_library(Foundation Foundation) - find_library(GLUT GLUT) - find_library(OpenGL OpenGL) - find_library(IOKit IOKit) - find_library(QTKit QTKit) - find_library(QuartzCore QuartzCore) - - target_link_libraries( - ${TARGET_NAME} - ${AppKit} - ${CoreAudio} - ${CoreServices} - ${Carbon} - ${Foundation} - ${GLUT} - ${OpenGL} - ${IOKit} - ${QTKit} - ${QuartzCore} - ) + # find_library(AppKit AppKit) + # find_library(CoreAudio CoreAudio) + # find_library(CoreServices CoreServices) + # find_library(Carbon Carbon) + # find_library(Foundation Foundation) + # find_library(GLUT GLUT) + # find_library(OpenGL OpenGL) + # find_library(IOKit IOKit) + # find_library(QTKit QTKit) + # find_library(QuartzCore QuartzCore) + # + # target_link_libraries( + # ${TARGET_NAME} + # ${AppKit} + # ${CoreAudio} + # ${CoreServices} + # ${Carbon} + # ${Foundation} + # ${GLUT} + # ${OpenGL} + # ${IOKit} + # ${QTKit} + # ${QuartzCore} + # ) # install command for OS X bundle INSTALL(TARGETS ${TARGET_NAME} diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 1ed0275a72..7891c65dcc 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -13,8 +13,7 @@ include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -find_package(Qt5Script) -find_package(Qt5Network) +find_package(Qt5 COMPONENTS Network Script) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Network) diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index 69cc61ca6d..ace5f9292c 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -20,7 +20,7 @@ include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -find_package(Qt5Network) +find_package(Qt5 COMPONENTS Network) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Network) diff --git a/libraries/audio/src/AudioRingBuffer.cpp b/libraries/audio/src/AudioRingBuffer.cpp index c687ab8648..cae663758d 100644 --- a/libraries/audio/src/AudioRingBuffer.cpp +++ b/libraries/audio/src/AudioRingBuffer.cpp @@ -15,9 +15,9 @@ #include -#include "PacketHeaders.h" -#include "AudioRingBuffer.h" +#include +#include "AudioRingBuffer.h" AudioRingBuffer::AudioRingBuffer(int numFrameSamples, bool randomAccessMode, int numFramesCapacity) : _frameCapacity(numFramesCapacity), diff --git a/libraries/audio/src/AudioRingBuffer.h b/libraries/audio/src/AudioRingBuffer.h index ed680b18b1..b4b30b1f56 100644 --- a/libraries/audio/src/AudioRingBuffer.h +++ b/libraries/audio/src/AudioRingBuffer.h @@ -15,12 +15,10 @@ #include #include -#include - #include -#include "NodeData.h" -#include "SharedUtil.h" +#include +#include const int SAMPLE_RATE = 24000; diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index 2aae671146..1300a2e733 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -19,8 +19,7 @@ link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -find_package(Qt5Network) -find_package(Qt5Script) +find_package(Qt5 COMPONENTS Network Script) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) diff --git a/libraries/embedded-webserver/CMakeLists.txt b/libraries/embedded-webserver/CMakeLists.txt index eb28cae1b3..5b815625ba 100644 --- a/libraries/embedded-webserver/CMakeLists.txt +++ b/libraries/embedded-webserver/CMakeLists.txt @@ -9,7 +9,7 @@ set(TARGET_NAME embedded-webserver) include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -find_package(Qt5Network REQUIRED) +find_package(Qt5 COMPONENTS Network) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Network) diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index 10feb55199..799a549a3b 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -19,9 +19,7 @@ link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -find_package(Qt5Script) -find_package(Qt5Widgets) -find_package(Qt5Network) +find_package(Qt5 COMPONENTS Network Script Widgets) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Widgets Qt5::Network) diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index 0d7b3cf4fc..8128741ef6 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -24,8 +24,7 @@ link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") # for streamable link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") -find_package(Qt5Network) -find_package(Qt5Script) +find_package(Qt5 COMPONENTS Network Script) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 2d47f7df9b..7bd210623b 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -6,7 +6,7 @@ set(TARGET_NAME networking) include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -find_package(Qt5Network) +find_package(Qt5 COMPONENTS Network) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Network) diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index ceac4324c0..54398ac252 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -19,11 +19,10 @@ link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") -find_package(Qt5Network) -find_package(Qt5Script) +find_package(Qt5 COMPONENTS Gui Network Script) # set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) +set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script Qt5::Gui) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index 2dd40c7ece..1b0199977f 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -6,8 +6,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cm set(TARGET_NAME script-engine) -find_package(Qt5Widgets REQUIRED) - include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) @@ -23,11 +21,12 @@ link_hifi_library(particles ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(models ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") -# link ZLIB -find_package(ZLIB) +find_package(Qt5 COMPONENTS Gui Network Script Widgets) -include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets) +# set a property indicating the libraries we are dependent on and link them to ourselves +set(DEPENDENCY_LIBRARIES Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 5faedff6ed..6badb10f8e 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -20,10 +20,9 @@ elseif (UNIX) set(DEPENDENCY_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") endif () -find_package(Qt5Network) -find_package(Qt5Widgets) +find_package(Qt5 COMPONENTS Network Widgets) # bubble up the libraries we are dependent on and link them to ourselves list(APPEND DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) +set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file From 0378fb30491b934c537e6b3d48325442f16f9e9b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 7 Aug 2014 17:09:27 -0700 Subject: [PATCH 09/43] break glm helpers out of SharedUtil --- assignment-client/CMakeLists.txt | 13 +- domain-server/CMakeLists.txt | 5 +- libraries/shared/src/AngularConstraint.cpp | 3 +- libraries/shared/src/AngularConstraint.h | 1 - libraries/shared/src/GLMHelpers.cpp | 299 +++++++++++++++++++++ libraries/shared/src/GLMHelpers.h | 89 ++++++ libraries/shared/src/SharedUtil.cpp | 290 -------------------- libraries/shared/src/SharedUtil.h | 69 ----- 8 files changed, 397 insertions(+), 372 deletions(-) create mode 100644 libraries/shared/src/GLMHelpers.cpp create mode 100644 libraries/shared/src/GLMHelpers.h diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 3fb0f574a5..2f3739485a 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -9,9 +9,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake include("${MACRO_DIR}/SetupHifiProject.cmake") setup_hifi_project(${TARGET_NAME} TRUE) -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - # link in the shared libraries include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") @@ -29,19 +26,15 @@ link_hifi_library(script-engine ${TARGET_NAME} "${ROOT_DIR}") link_hifi_library(embedded-webserver ${TARGET_NAME} "${ROOT_DIR}") if (UNIX) - list(APPEND DEPENDENCY_LIBRARIES ${CMAKE_DL_LIBS}) + target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} ${CMAKE_DL_LIBS}) endif (UNIX) IF (WIN32) - list(APPEND DEPENDENCY_LIBRARIES Winmm Ws2_32) + target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} Winmm Ws2_32) ENDIF(WIN32) find_package(Qt5 COMPONENTS Gui Network Script Widgets) - -# set a property indicating the libraries we are dependent on and link them to ourselves -list(APPEND DEPENDENCY_LIBRARIES Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) # add a definition for ssize_t so that windows doesn't bail if (WIN32) diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 26f07cf776..656760957d 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -32,4 +32,7 @@ ENDIF(WIN32) # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) -endif () \ No newline at end of file +endif () + +find_package(Qt5 COMPONENTS Network) +target_link_libraries(${TARGET_NAME} Qt5::Network) diff --git a/libraries/shared/src/AngularConstraint.cpp b/libraries/shared/src/AngularConstraint.cpp index 4689568ac8..b39823ee3b 100644 --- a/libraries/shared/src/AngularConstraint.cpp +++ b/libraries/shared/src/AngularConstraint.cpp @@ -11,8 +11,9 @@ #include +#include "GLMHelpers.h" + #include "AngularConstraint.h" -#include "SharedUtil.h" // helper function /// \param angle radian angle to be clamped within angleMin and angleMax diff --git a/libraries/shared/src/AngularConstraint.h b/libraries/shared/src/AngularConstraint.h index 929a58959b..74d3fdb82b 100644 --- a/libraries/shared/src/AngularConstraint.h +++ b/libraries/shared/src/AngularConstraint.h @@ -14,7 +14,6 @@ #include - class AngularConstraint { public: /// \param minAngles minumum euler angles for the constraint diff --git a/libraries/shared/src/GLMHelpers.cpp b/libraries/shared/src/GLMHelpers.cpp new file mode 100644 index 0000000000..566983679b --- /dev/null +++ b/libraries/shared/src/GLMHelpers.cpp @@ -0,0 +1,299 @@ +// +// GLMHelpers.cpp +// libraries/shared/src +// +// Created by Stephen Birarda on 2014-08-07. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include "GLMHelpers.h" + +// Safe version of glm::mix; based on the code in Nick Bobick's article, +// http://www.gamasutra.com/features/19980703/quaternions_01.htm (via Clyde, +// https://github.com/threerings/clyde/blob/master/src/main/java/com/threerings/math/Quaternion.java) +glm::quat safeMix(const glm::quat& q1, const glm::quat& q2, float proportion) { + float cosa = q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w; + float ox = q2.x, oy = q2.y, oz = q2.z, ow = q2.w, s0, s1; + + // adjust signs if necessary + if (cosa < 0.0f) { + cosa = -cosa; + ox = -ox; + oy = -oy; + oz = -oz; + ow = -ow; + } + + // calculate coefficients; if the angle is too close to zero, we must fall back + // to linear interpolation + if ((1.0f - cosa) > EPSILON) { + float angle = acosf(cosa), sina = sinf(angle); + s0 = sinf((1.0f - proportion) * angle) / sina; + s1 = sinf(proportion * angle) / sina; + + } else { + s0 = 1.0f - proportion; + s1 = proportion; + } + + return glm::normalize(glm::quat(s0 * q1.w + s1 * ow, s0 * q1.x + s1 * ox, s0 * q1.y + s1 * oy, s0 * q1.z + s1 * oz)); +} + +// Allows sending of fixed-point numbers: radix 1 makes 15.1 number, radix 8 makes 8.8 number, etc +int packFloatScalarToSignedTwoByteFixed(unsigned char* buffer, float scalar, int radix) { + int16_t outVal = (int16_t)(scalar * (float)(1 << radix)); + memcpy(buffer, &outVal, sizeof(uint16_t)); + return sizeof(uint16_t); +} + +int unpackFloatScalarFromSignedTwoByteFixed(const int16_t* byteFixedPointer, float* destinationPointer, int radix) { + *destinationPointer = *byteFixedPointer / (float)(1 << radix); + return sizeof(int16_t); +} + +int packFloatVec3ToSignedTwoByteFixed(unsigned char* destBuffer, const glm::vec3& srcVector, int radix) { + const unsigned char* startPosition = destBuffer; + destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.x, radix); + destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.y, radix); + destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.z, radix); + return destBuffer - startPosition; +} + +int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm::vec3& destination, int radix) { + const unsigned char* startPosition = sourceBuffer; + sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.x), radix); + sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.y), radix); + sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.z), radix); + return sourceBuffer - startPosition; +} + + +int packFloatAngleToTwoByte(unsigned char* buffer, float degrees) { + const float ANGLE_CONVERSION_RATIO = (std::numeric_limits::max() / 360.f); + + uint16_t angleHolder = floorf((degrees + 180.f) * ANGLE_CONVERSION_RATIO); + memcpy(buffer, &angleHolder, sizeof(uint16_t)); + + return sizeof(uint16_t); +} + +int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destinationPointer) { + *destinationPointer = (*byteAnglePointer / (float) std::numeric_limits::max()) * 360.f - 180.f; + return sizeof(uint16_t); +} + +int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput) { + const float QUAT_PART_CONVERSION_RATIO = (std::numeric_limits::max() / 2.f); + uint16_t quatParts[4]; + quatParts[0] = floorf((quatInput.x + 1.f) * QUAT_PART_CONVERSION_RATIO); + quatParts[1] = floorf((quatInput.y + 1.f) * QUAT_PART_CONVERSION_RATIO); + quatParts[2] = floorf((quatInput.z + 1.f) * QUAT_PART_CONVERSION_RATIO); + quatParts[3] = floorf((quatInput.w + 1.f) * QUAT_PART_CONVERSION_RATIO); + + memcpy(buffer, &quatParts, sizeof(quatParts)); + return sizeof(quatParts); +} + +int unpackOrientationQuatFromBytes(const unsigned char* buffer, glm::quat& quatOutput) { + uint16_t quatParts[4]; + memcpy(&quatParts, buffer, sizeof(quatParts)); + + quatOutput.x = ((quatParts[0] / (float) std::numeric_limits::max()) * 2.f) - 1.f; + quatOutput.y = ((quatParts[1] / (float) std::numeric_limits::max()) * 2.f) - 1.f; + quatOutput.z = ((quatParts[2] / (float) std::numeric_limits::max()) * 2.f) - 1.f; + quatOutput.w = ((quatParts[3] / (float) std::numeric_limits::max()) * 2.f) - 1.f; + + return sizeof(quatParts); +} + +// Safe version of glm::eulerAngles; uses the factorization method described in David Eberly's +// http://www.geometrictools.com/Documentation/EulerAngles.pdf (via Clyde, +// https://github.com/threerings/clyde/blob/master/src/main/java/com/threerings/math/Quaternion.java) +glm::vec3 safeEulerAngles(const glm::quat& q) { + float sy = 2.0f * (q.y * q.w - q.x * q.z); + glm::vec3 eulers; + if (sy < 1.0f - EPSILON) { + if (sy > -1.0f + EPSILON) { + eulers = glm::vec3( + atan2f(q.y * q.z + q.x * q.w, 0.5f - (q.x * q.x + q.y * q.y)), + asinf(sy), + atan2f(q.x * q.y + q.z * q.w, 0.5f - (q.y * q.y + q.z * q.z))); + + } else { + // not a unique solution; x + z = atan2(-m21, m11) + eulers = glm::vec3( + 0.0f, + - PI_OVER_TWO, + atan2f(q.x * q.w - q.y * q.z, 0.5f - (q.x * q.x + q.z * q.z))); + } + } else { + // not a unique solution; x - z = atan2(-m21, m11) + eulers = glm::vec3( + 0.0f, + PI_OVER_TWO, + -atan2f(q.x * q.w - q.y * q.z, 0.5f - (q.x * q.x + q.z * q.z))); + } + + // adjust so that z, rather than y, is in [-pi/2, pi/2] + if (eulers.z < -PI_OVER_TWO) { + if (eulers.x < 0.0f) { + eulers.x += PI; + } else { + eulers.x -= PI; + } + eulers.y = -eulers.y; + if (eulers.y < 0.0f) { + eulers.y += PI; + } else { + eulers.y -= PI; + } + eulers.z += PI; + + } else if (eulers.z > PI_OVER_TWO) { + if (eulers.x < 0.0f) { + eulers.x += PI; + } else { + eulers.x -= PI; + } + eulers.y = -eulers.y; + if (eulers.y < 0.0f) { + eulers.y += PI; + } else { + eulers.y -= PI; + } + eulers.z -= PI; + } + return eulers; +} + +// Helper function returns the positive angle (in radians) between two 3D vectors +float angleBetween(const glm::vec3& v1, const glm::vec3& v2) { + return acosf((glm::dot(v1, v2)) / (glm::length(v1) * glm::length(v2))); +} + +// Helper function return the rotation from the first vector onto the second +glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2) { + float angle = angleBetween(v1, v2); + if (glm::isnan(angle) || angle < EPSILON) { + return glm::quat(); + } + glm::vec3 axis; + if (angle > 179.99f * RADIANS_PER_DEGREE) { // 180 degree rotation; must use another axis + axis = glm::cross(v1, glm::vec3(1.0f, 0.0f, 0.0f)); + float axisLength = glm::length(axis); + if (axisLength < EPSILON) { // parallel to x; y will work + axis = glm::normalize(glm::cross(v1, glm::vec3(0.0f, 1.0f, 0.0f))); + } else { + axis /= axisLength; + } + } else { + axis = glm::normalize(glm::cross(v1, v2)); + // It is possible for axis to be nan even when angle is not less than EPSILON. + // For example when angle is small but not tiny but v1 and v2 and have very short lengths. + if (glm::isnan(glm::dot(axis, axis))) { + // set angle and axis to values that will generate an identity rotation + angle = 0.0f; + axis = glm::vec3(1.0f, 0.0f, 0.0f); + } + } + return glm::angleAxis(angle, axis); +} + +glm::vec3 extractTranslation(const glm::mat4& matrix) { + return glm::vec3(matrix[3][0], matrix[3][1], matrix[3][2]); +} + +void setTranslation(glm::mat4& matrix, const glm::vec3& translation) { + matrix[3][0] = translation.x; + matrix[3][1] = translation.y; + matrix[3][2] = translation.z; +} + +glm::quat extractRotation(const glm::mat4& matrix, bool assumeOrthogonal) { + // uses the iterative polar decomposition algorithm described by Ken Shoemake at + // http://www.cs.wisc.edu/graphics/Courses/838-s2002/Papers/polar-decomp.pdf + // code adapted from Clyde, https://github.com/threerings/clyde/blob/master/core/src/main/java/com/threerings/math/Matrix4f.java + // start with the contents of the upper 3x3 portion of the matrix + glm::mat3 upper = glm::mat3(matrix); + if (!assumeOrthogonal) { + for (int i = 0; i < 10; i++) { + // store the results of the previous iteration + glm::mat3 previous = upper; + + // compute average of the matrix with its inverse transpose + float sd00 = previous[1][1] * previous[2][2] - previous[2][1] * previous[1][2]; + float sd10 = previous[0][1] * previous[2][2] - previous[2][1] * previous[0][2]; + float sd20 = previous[0][1] * previous[1][2] - previous[1][1] * previous[0][2]; + float det = previous[0][0] * sd00 + previous[2][0] * sd20 - previous[1][0] * sd10; + if (fabs(det) == 0.0f) { + // determinant is zero; matrix is not invertible + break; + } + float hrdet = 0.5f / det; + upper[0][0] = +sd00 * hrdet + previous[0][0] * 0.5f; + upper[1][0] = -sd10 * hrdet + previous[1][0] * 0.5f; + upper[2][0] = +sd20 * hrdet + previous[2][0] * 0.5f; + + upper[0][1] = -(previous[1][0] * previous[2][2] - previous[2][0] * previous[1][2]) * hrdet + previous[0][1] * 0.5f; + upper[1][1] = +(previous[0][0] * previous[2][2] - previous[2][0] * previous[0][2]) * hrdet + previous[1][1] * 0.5f; + upper[2][1] = -(previous[0][0] * previous[1][2] - previous[1][0] * previous[0][2]) * hrdet + previous[2][1] * 0.5f; + + upper[0][2] = +(previous[1][0] * previous[2][1] - previous[2][0] * previous[1][1]) * hrdet + previous[0][2] * 0.5f; + upper[1][2] = -(previous[0][0] * previous[2][1] - previous[2][0] * previous[0][1]) * hrdet + previous[1][2] * 0.5f; + upper[2][2] = +(previous[0][0] * previous[1][1] - previous[1][0] * previous[0][1]) * hrdet + previous[2][2] * 0.5f; + + // compute the difference; if it's small enough, we're done + glm::mat3 diff = upper - previous; + if (diff[0][0] * diff[0][0] + diff[1][0] * diff[1][0] + diff[2][0] * diff[2][0] + diff[0][1] * diff[0][1] + + diff[1][1] * diff[1][1] + diff[2][1] * diff[2][1] + diff[0][2] * diff[0][2] + diff[1][2] * diff[1][2] + + diff[2][2] * diff[2][2] < EPSILON) { + break; + } + } + } + + // now that we have a nice orthogonal matrix, we can extract the rotation quaternion + // using the method described in http://en.wikipedia.org/wiki/Rotation_matrix#Conversions + float x2 = fabs(1.0f + upper[0][0] - upper[1][1] - upper[2][2]); + float y2 = fabs(1.0f - upper[0][0] + upper[1][1] - upper[2][2]); + float z2 = fabs(1.0f - upper[0][0] - upper[1][1] + upper[2][2]); + float w2 = fabs(1.0f + upper[0][0] + upper[1][1] + upper[2][2]); + return glm::normalize(glm::quat(0.5f * sqrtf(w2), + 0.5f * sqrtf(x2) * (upper[1][2] >= upper[2][1] ? 1.0f : -1.0f), + 0.5f * sqrtf(y2) * (upper[2][0] >= upper[0][2] ? 1.0f : -1.0f), + 0.5f * sqrtf(z2) * (upper[0][1] >= upper[1][0] ? 1.0f : -1.0f))); +} + +glm::vec3 extractScale(const glm::mat4& matrix) { + return glm::vec3(glm::length(matrix[0]), glm::length(matrix[1]), glm::length(matrix[2])); +} + +float extractUniformScale(const glm::mat4& matrix) { + return extractUniformScale(extractScale(matrix)); +} + +float extractUniformScale(const glm::vec3& scale) { + return (scale.x + scale.y + scale.z) / 3.0f; +} + +QByteArray createByteArray(const glm::vec3& vector) { + return QByteArray::number(vector.x) + ',' + QByteArray::number(vector.y) + ',' + QByteArray::number(vector.z); +} + +bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB, float similarEnough) { + // Compute the angular distance between the two orientations + float angleOrientation = orientionA == orientionB ? 0.0f : glm::degrees(glm::angle(orientionA * glm::inverse(orientionB))); + if (isNaN(angleOrientation)) { + angleOrientation = 0.0f; + } + return (angleOrientation <= similarEnough); +} + +bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough) { + // Compute the distance between the two points + float positionDistance = glm::distance(positionA, positionB); + return (positionDistance <= similarEnough); +} \ No newline at end of file diff --git a/libraries/shared/src/GLMHelpers.h b/libraries/shared/src/GLMHelpers.h new file mode 100644 index 0000000000..43a1d09722 --- /dev/null +++ b/libraries/shared/src/GLMHelpers.h @@ -0,0 +1,89 @@ +// +// GLMHelpers.h +// libraries/shared/src +// +// Created by Stephen Birarda on 2014-08-07. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_GLMHelpers_h +#define hifi_GLMHelpers_h + +#include + +#include +#include + +#include + +#include "SharedUtil.h" + +glm::quat safeMix(const glm::quat& q1, const glm::quat& q2, float alpha); + +// These pack/unpack functions are designed to start specific known types in as efficient a manner +// as possible. Taking advantage of the known characteristics of the semantic types. + +// Angles are known to be between 0 and 360 degrees, this allows us to encode in 16bits with great accuracy +int packFloatAngleToTwoByte(unsigned char* buffer, float degrees); +int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destinationPointer); + +// Orientation Quats are known to have 4 normalized components be between -1.0 and 1.0 +// this allows us to encode each component in 16bits with great accuracy +int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput); +int unpackOrientationQuatFromBytes(const unsigned char* buffer, glm::quat& quatOutput); + +// Ratios need the be highly accurate when less than 10, but not very accurate above 10, and they +// are never greater than 1000 to 1, this allows us to encode each component in 16bits +int packFloatRatioToTwoByte(unsigned char* buffer, float ratio); +int unpackFloatRatioFromTwoByte(const unsigned char* buffer, float& ratio); + +// Near/Far Clip values need the be highly accurate when less than 10, but only integer accuracy above 10 and +// they are never greater than 16,000, this allows us to encode each component in 16bits +int packClipValueToTwoByte(unsigned char* buffer, float clipValue); +int unpackClipValueFromTwoByte(const unsigned char* buffer, float& clipValue); + +// Positive floats that don't need to be very precise +int packFloatToByte(unsigned char* buffer, float value, float scaleBy); +int unpackFloatFromByte(const unsigned char* buffer, float& value, float scaleBy); + +// Allows sending of fixed-point numbers: radix 1 makes 15.1 number, radix 8 makes 8.8 number, etc +int packFloatScalarToSignedTwoByteFixed(unsigned char* buffer, float scalar, int radix); +int unpackFloatScalarFromSignedTwoByteFixed(const int16_t* byteFixedPointer, float* destinationPointer, int radix); + +// A convenience for sending vec3's as fixed-point floats +int packFloatVec3ToSignedTwoByteFixed(unsigned char* destBuffer, const glm::vec3& srcVector, int radix); +int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm::vec3& destination, int radix); + +/// \return vec3 with euler angles in radians +glm::vec3 safeEulerAngles(const glm::quat& q); + +float angleBetween(const glm::vec3& v1, const glm::vec3& v2); + +glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2); + +glm::vec3 extractTranslation(const glm::mat4& matrix); + +void setTranslation(glm::mat4& matrix, const glm::vec3& translation); + +glm::quat extractRotation(const glm::mat4& matrix, bool assumeOrthogonal = false); + +glm::vec3 extractScale(const glm::mat4& matrix); + +float extractUniformScale(const glm::mat4& matrix); + +float extractUniformScale(const glm::vec3& scale); + +QByteArray createByteArray(const glm::vec3& vector); + +/// \return bool are two orientations similar to each other +const float ORIENTATION_SIMILAR_ENOUGH = 5.0f; // 10 degrees in any direction +bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB, + float similarEnough = ORIENTATION_SIMILAR_ENOUGH); +const float POSITION_SIMILAR_ENOUGH = 0.1f; // 0.1 meter +bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough = POSITION_SIMILAR_ENOUGH); + + +#endif // hifi_GLMHelpers_h \ No newline at end of file diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index 2b8b9929e5..470dfffd13 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -79,40 +79,6 @@ bool shouldDo(float desiredInterval, float deltaTime) { return randFloat() < deltaTime / desiredInterval; } -// Safe version of glm::mix; based on the code in Nick Bobick's article, -// http://www.gamasutra.com/features/19980703/quaternions_01.htm (via Clyde, -// https://github.com/threerings/clyde/blob/master/src/main/java/com/threerings/math/Quaternion.java) -glm::quat safeMix(const glm::quat& q1, const glm::quat& q2, float proportion) { - float cosa = q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w; - float ox = q2.x, oy = q2.y, oz = q2.z, ow = q2.w, s0, s1; - - // adjust signs if necessary - if (cosa < 0.0f) { - cosa = -cosa; - ox = -ox; - oy = -oy; - oz = -oz; - ow = -ow; - } - - // calculate coefficients; if the angle is too close to zero, we must fall back - // to linear interpolation - if ((1.0f - cosa) > EPSILON) { - float angle = acosf(cosa), sina = sinf(angle); - s0 = sinf((1.0f - proportion) * angle) / sina; - s1 = sinf(proportion * angle) / sina; - - } else { - s0 = 1.0f - proportion; - s1 = proportion; - } - - return glm::normalize(glm::quat(s0 * q1.w + s1 * ow, s0 * q1.x + s1 * ox, s0 * q1.y + s1 * oy, s0 * q1.z + s1 * oz)); -} - - - - void outputBufferBits(const unsigned char* buffer, int length, QDebug* continuedDebug) { for (int i = 0; i < length; i++) { outputBits(buffer[i], continuedDebug); @@ -489,73 +455,6 @@ int removeFromSortedArrays(void* value, void** valueArray, float* keyArray, int* return -1; // error case } -// Allows sending of fixed-point numbers: radix 1 makes 15.1 number, radix 8 makes 8.8 number, etc -int packFloatScalarToSignedTwoByteFixed(unsigned char* buffer, float scalar, int radix) { - int16_t outVal = (int16_t)(scalar * (float)(1 << radix)); - memcpy(buffer, &outVal, sizeof(uint16_t)); - return sizeof(uint16_t); -} - -int unpackFloatScalarFromSignedTwoByteFixed(const int16_t* byteFixedPointer, float* destinationPointer, int radix) { - *destinationPointer = *byteFixedPointer / (float)(1 << radix); - return sizeof(int16_t); -} - -int packFloatVec3ToSignedTwoByteFixed(unsigned char* destBuffer, const glm::vec3& srcVector, int radix) { - const unsigned char* startPosition = destBuffer; - destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.x, radix); - destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.y, radix); - destBuffer += packFloatScalarToSignedTwoByteFixed(destBuffer, srcVector.z, radix); - return destBuffer - startPosition; -} - -int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm::vec3& destination, int radix) { - const unsigned char* startPosition = sourceBuffer; - sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.x), radix); - sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.y), radix); - sourceBuffer += unpackFloatScalarFromSignedTwoByteFixed((int16_t*) sourceBuffer, &(destination.z), radix); - return sourceBuffer - startPosition; -} - - -int packFloatAngleToTwoByte(unsigned char* buffer, float degrees) { - const float ANGLE_CONVERSION_RATIO = (std::numeric_limits::max() / 360.f); - - uint16_t angleHolder = floorf((degrees + 180.f) * ANGLE_CONVERSION_RATIO); - memcpy(buffer, &angleHolder, sizeof(uint16_t)); - - return sizeof(uint16_t); -} - -int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destinationPointer) { - *destinationPointer = (*byteAnglePointer / (float) std::numeric_limits::max()) * 360.f - 180.f; - return sizeof(uint16_t); -} - -int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput) { - const float QUAT_PART_CONVERSION_RATIO = (std::numeric_limits::max() / 2.f); - uint16_t quatParts[4]; - quatParts[0] = floorf((quatInput.x + 1.f) * QUAT_PART_CONVERSION_RATIO); - quatParts[1] = floorf((quatInput.y + 1.f) * QUAT_PART_CONVERSION_RATIO); - quatParts[2] = floorf((quatInput.z + 1.f) * QUAT_PART_CONVERSION_RATIO); - quatParts[3] = floorf((quatInput.w + 1.f) * QUAT_PART_CONVERSION_RATIO); - - memcpy(buffer, &quatParts, sizeof(quatParts)); - return sizeof(quatParts); -} - -int unpackOrientationQuatFromBytes(const unsigned char* buffer, glm::quat& quatOutput) { - uint16_t quatParts[4]; - memcpy(&quatParts, buffer, sizeof(quatParts)); - - quatOutput.x = ((quatParts[0] / (float) std::numeric_limits::max()) * 2.f) - 1.f; - quatOutput.y = ((quatParts[1] / (float) std::numeric_limits::max()) * 2.f) - 1.f; - quatOutput.z = ((quatParts[2] / (float) std::numeric_limits::max()) * 2.f) - 1.f; - quatOutput.w = ((quatParts[3] / (float) std::numeric_limits::max()) * 2.f) - 1.f; - - return sizeof(quatParts); -} - float SMALL_LIMIT = 10.f; float LARGE_LIMIT = 1000.f; @@ -651,199 +550,10 @@ void debug::checkDeadBeef(void* memoryVoid, int size) { assert(memcmp((unsigned char*)memoryVoid, DEADBEEF, std::min(size, DEADBEEF_SIZE)) != 0); } -// Safe version of glm::eulerAngles; uses the factorization method described in David Eberly's -// http://www.geometrictools.com/Documentation/EulerAngles.pdf (via Clyde, -// https://github.com/threerings/clyde/blob/master/src/main/java/com/threerings/math/Quaternion.java) -glm::vec3 safeEulerAngles(const glm::quat& q) { - float sy = 2.0f * (q.y * q.w - q.x * q.z); - glm::vec3 eulers; - if (sy < 1.0f - EPSILON) { - if (sy > -1.0f + EPSILON) { - eulers = glm::vec3( - atan2f(q.y * q.z + q.x * q.w, 0.5f - (q.x * q.x + q.y * q.y)), - asinf(sy), - atan2f(q.x * q.y + q.z * q.w, 0.5f - (q.y * q.y + q.z * q.z))); - - } else { - // not a unique solution; x + z = atan2(-m21, m11) - eulers = glm::vec3( - 0.0f, - - PI_OVER_TWO, - atan2f(q.x * q.w - q.y * q.z, 0.5f - (q.x * q.x + q.z * q.z))); - } - } else { - // not a unique solution; x - z = atan2(-m21, m11) - eulers = glm::vec3( - 0.0f, - PI_OVER_TWO, - -atan2f(q.x * q.w - q.y * q.z, 0.5f - (q.x * q.x + q.z * q.z))); - } - - // adjust so that z, rather than y, is in [-pi/2, pi/2] - if (eulers.z < -PI_OVER_TWO) { - if (eulers.x < 0.0f) { - eulers.x += PI; - } else { - eulers.x -= PI; - } - eulers.y = -eulers.y; - if (eulers.y < 0.0f) { - eulers.y += PI; - } else { - eulers.y -= PI; - } - eulers.z += PI; - - } else if (eulers.z > PI_OVER_TWO) { - if (eulers.x < 0.0f) { - eulers.x += PI; - } else { - eulers.x -= PI; - } - eulers.y = -eulers.y; - if (eulers.y < 0.0f) { - eulers.y += PI; - } else { - eulers.y -= PI; - } - eulers.z -= PI; - } - return eulers; -} - -// Helper function returns the positive angle (in radians) between two 3D vectors -float angleBetween(const glm::vec3& v1, const glm::vec3& v2) { - return acosf((glm::dot(v1, v2)) / (glm::length(v1) * glm::length(v2))); -} - -// Helper function return the rotation from the first vector onto the second -glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2) { - float angle = angleBetween(v1, v2); - if (glm::isnan(angle) || angle < EPSILON) { - return glm::quat(); - } - glm::vec3 axis; - if (angle > 179.99f * RADIANS_PER_DEGREE) { // 180 degree rotation; must use another axis - axis = glm::cross(v1, glm::vec3(1.0f, 0.0f, 0.0f)); - float axisLength = glm::length(axis); - if (axisLength < EPSILON) { // parallel to x; y will work - axis = glm::normalize(glm::cross(v1, glm::vec3(0.0f, 1.0f, 0.0f))); - } else { - axis /= axisLength; - } - } else { - axis = glm::normalize(glm::cross(v1, v2)); - // It is possible for axis to be nan even when angle is not less than EPSILON. - // For example when angle is small but not tiny but v1 and v2 and have very short lengths. - if (glm::isnan(glm::dot(axis, axis))) { - // set angle and axis to values that will generate an identity rotation - angle = 0.0f; - axis = glm::vec3(1.0f, 0.0f, 0.0f); - } - } - return glm::angleAxis(angle, axis); -} - -glm::vec3 extractTranslation(const glm::mat4& matrix) { - return glm::vec3(matrix[3][0], matrix[3][1], matrix[3][2]); -} - -void setTranslation(glm::mat4& matrix, const glm::vec3& translation) { - matrix[3][0] = translation.x; - matrix[3][1] = translation.y; - matrix[3][2] = translation.z; -} - -glm::quat extractRotation(const glm::mat4& matrix, bool assumeOrthogonal) { - // uses the iterative polar decomposition algorithm described by Ken Shoemake at - // http://www.cs.wisc.edu/graphics/Courses/838-s2002/Papers/polar-decomp.pdf - // code adapted from Clyde, https://github.com/threerings/clyde/blob/master/core/src/main/java/com/threerings/math/Matrix4f.java - // start with the contents of the upper 3x3 portion of the matrix - glm::mat3 upper = glm::mat3(matrix); - if (!assumeOrthogonal) { - for (int i = 0; i < 10; i++) { - // store the results of the previous iteration - glm::mat3 previous = upper; - - // compute average of the matrix with its inverse transpose - float sd00 = previous[1][1] * previous[2][2] - previous[2][1] * previous[1][2]; - float sd10 = previous[0][1] * previous[2][2] - previous[2][1] * previous[0][2]; - float sd20 = previous[0][1] * previous[1][2] - previous[1][1] * previous[0][2]; - float det = previous[0][0] * sd00 + previous[2][0] * sd20 - previous[1][0] * sd10; - if (fabs(det) == 0.0f) { - // determinant is zero; matrix is not invertible - break; - } - float hrdet = 0.5f / det; - upper[0][0] = +sd00 * hrdet + previous[0][0] * 0.5f; - upper[1][0] = -sd10 * hrdet + previous[1][0] * 0.5f; - upper[2][0] = +sd20 * hrdet + previous[2][0] * 0.5f; - - upper[0][1] = -(previous[1][0] * previous[2][2] - previous[2][0] * previous[1][2]) * hrdet + previous[0][1] * 0.5f; - upper[1][1] = +(previous[0][0] * previous[2][2] - previous[2][0] * previous[0][2]) * hrdet + previous[1][1] * 0.5f; - upper[2][1] = -(previous[0][0] * previous[1][2] - previous[1][0] * previous[0][2]) * hrdet + previous[2][1] * 0.5f; - - upper[0][2] = +(previous[1][0] * previous[2][1] - previous[2][0] * previous[1][1]) * hrdet + previous[0][2] * 0.5f; - upper[1][2] = -(previous[0][0] * previous[2][1] - previous[2][0] * previous[0][1]) * hrdet + previous[1][2] * 0.5f; - upper[2][2] = +(previous[0][0] * previous[1][1] - previous[1][0] * previous[0][1]) * hrdet + previous[2][2] * 0.5f; - - // compute the difference; if it's small enough, we're done - glm::mat3 diff = upper - previous; - if (diff[0][0] * diff[0][0] + diff[1][0] * diff[1][0] + diff[2][0] * diff[2][0] + diff[0][1] * diff[0][1] + - diff[1][1] * diff[1][1] + diff[2][1] * diff[2][1] + diff[0][2] * diff[0][2] + diff[1][2] * diff[1][2] + - diff[2][2] * diff[2][2] < EPSILON) { - break; - } - } - } - - // now that we have a nice orthogonal matrix, we can extract the rotation quaternion - // using the method described in http://en.wikipedia.org/wiki/Rotation_matrix#Conversions - float x2 = fabs(1.0f + upper[0][0] - upper[1][1] - upper[2][2]); - float y2 = fabs(1.0f - upper[0][0] + upper[1][1] - upper[2][2]); - float z2 = fabs(1.0f - upper[0][0] - upper[1][1] + upper[2][2]); - float w2 = fabs(1.0f + upper[0][0] + upper[1][1] + upper[2][2]); - return glm::normalize(glm::quat(0.5f * sqrtf(w2), - 0.5f * sqrtf(x2) * (upper[1][2] >= upper[2][1] ? 1.0f : -1.0f), - 0.5f * sqrtf(y2) * (upper[2][0] >= upper[0][2] ? 1.0f : -1.0f), - 0.5f * sqrtf(z2) * (upper[0][1] >= upper[1][0] ? 1.0f : -1.0f))); -} - -glm::vec3 extractScale(const glm::mat4& matrix) { - return glm::vec3(glm::length(matrix[0]), glm::length(matrix[1]), glm::length(matrix[2])); -} - -float extractUniformScale(const glm::mat4& matrix) { - return extractUniformScale(extractScale(matrix)); -} - -float extractUniformScale(const glm::vec3& scale) { - return (scale.x + scale.y + scale.z) / 3.0f; -} - bool isNaN(float value) { return value != value; } -bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB, float similarEnough) { - // Compute the angular distance between the two orientations - float angleOrientation = orientionA == orientionB ? 0.0f : glm::degrees(glm::angle(orientionA * glm::inverse(orientionB))); - if (isNaN(angleOrientation)) { - angleOrientation = 0.0f; - } - return (angleOrientation <= similarEnough); -} - -bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough) { - // Compute the distance between the two points - float positionDistance = glm::distance(positionA, positionB); - return (positionDistance <= similarEnough); -} - -QByteArray createByteArray(const glm::vec3& vector) { - return QByteArray::number(vector.x) + ',' + QByteArray::number(vector.y) + ',' + QByteArray::number(vector.z); -} - QString formatUsecTime(float usecs, int prec) { static const quint64 SECONDS_PER_MINUTE = 60; static const quint64 USECS_PER_MINUTE = USECS_PER_SECOND * SECONDS_PER_MINUTE; diff --git a/libraries/shared/src/SharedUtil.h b/libraries/shared/src/SharedUtil.h index 18494d48e4..015758427a 100644 --- a/libraries/shared/src/SharedUtil.h +++ b/libraries/shared/src/SharedUtil.h @@ -19,9 +19,6 @@ #include // not on windows, not needed for mac or windows #endif -#include -#include - #include const int BYTES_PER_COLOR = 3; @@ -71,8 +68,6 @@ float randomSign(); /// \return -1.0 or 1.0 unsigned char randomColorValue(int minimum = 0); bool randomBoolean(); -glm::quat safeMix(const glm::quat& q1, const glm::quat& q2, float alpha); - bool shouldDo(float desiredInterval, float deltaTime); void outputBufferBits(const unsigned char* buffer, int length, QDebug* continuedDebug = NULL); @@ -108,8 +103,6 @@ int insertIntoSortedArrays(void* value, float key, int originalIndex, int removeFromSortedArrays(void* value, void** valueArray, float* keyArray, int* originalIndexArray, int currentCount, int maxCount); - - // Helper Class for debugging class debug { public: @@ -124,71 +117,9 @@ private: bool isBetween(int64_t value, int64_t max, int64_t min); -// These pack/unpack functions are designed to start specific known types in as efficient a manner -// as possible. Taking advantage of the known characteristics of the semantic types. - -// Angles are known to be between 0 and 360 degrees, this allows us to encode in 16bits with great accuracy -int packFloatAngleToTwoByte(unsigned char* buffer, float degrees); -int unpackFloatAngleFromTwoByte(const uint16_t* byteAnglePointer, float* destinationPointer); - -// Orientation Quats are known to have 4 normalized components be between -1.0 and 1.0 -// this allows us to encode each component in 16bits with great accuracy -int packOrientationQuatToBytes(unsigned char* buffer, const glm::quat& quatInput); -int unpackOrientationQuatFromBytes(const unsigned char* buffer, glm::quat& quatOutput); - -// Ratios need the be highly accurate when less than 10, but not very accurate above 10, and they -// are never greater than 1000 to 1, this allows us to encode each component in 16bits -int packFloatRatioToTwoByte(unsigned char* buffer, float ratio); -int unpackFloatRatioFromTwoByte(const unsigned char* buffer, float& ratio); - -// Near/Far Clip values need the be highly accurate when less than 10, but only integer accuracy above 10 and -// they are never greater than 16,000, this allows us to encode each component in 16bits -int packClipValueToTwoByte(unsigned char* buffer, float clipValue); -int unpackClipValueFromTwoByte(const unsigned char* buffer, float& clipValue); - -// Positive floats that don't need to be very precise -int packFloatToByte(unsigned char* buffer, float value, float scaleBy); -int unpackFloatFromByte(const unsigned char* buffer, float& value, float scaleBy); - -// Allows sending of fixed-point numbers: radix 1 makes 15.1 number, radix 8 makes 8.8 number, etc -int packFloatScalarToSignedTwoByteFixed(unsigned char* buffer, float scalar, int radix); -int unpackFloatScalarFromSignedTwoByteFixed(const int16_t* byteFixedPointer, float* destinationPointer, int radix); - -// A convenience for sending vec3's as fixed-point floats -int packFloatVec3ToSignedTwoByteFixed(unsigned char* destBuffer, const glm::vec3& srcVector, int radix); -int unpackFloatVec3FromSignedTwoByteFixed(const unsigned char* sourceBuffer, glm::vec3& destination, int radix); - -/// \return vec3 with euler angles in radians -glm::vec3 safeEulerAngles(const glm::quat& q); - -float angleBetween(const glm::vec3& v1, const glm::vec3& v2); - -glm::quat rotationBetween(const glm::vec3& v1, const glm::vec3& v2); - -glm::vec3 extractTranslation(const glm::mat4& matrix); - -void setTranslation(glm::mat4& matrix, const glm::vec3& translation); - -glm::quat extractRotation(const glm::mat4& matrix, bool assumeOrthogonal = false); - -glm::vec3 extractScale(const glm::mat4& matrix); - -float extractUniformScale(const glm::mat4& matrix); - -float extractUniformScale(const glm::vec3& scale); - -/// \return bool are two orientations similar to each other -const float ORIENTATION_SIMILAR_ENOUGH = 5.0f; // 10 degrees in any direction -bool isSimilarOrientation(const glm::quat& orientionA, const glm::quat& orientionB, - float similarEnough = ORIENTATION_SIMILAR_ENOUGH); -const float POSITION_SIMILAR_ENOUGH = 0.1f; // 0.1 meter -bool isSimilarPosition(const glm::vec3& positionA, const glm::vec3& positionB, float similarEnough = POSITION_SIMILAR_ENOUGH); - /// \return bool is the float NaN bool isNaN(float value); -QByteArray createByteArray(const glm::vec3& vector); - QString formatUsecTime(float usecs, int prec = 3); #endif // hifi_SharedUtil_h From 31488e72fe95ff5b459e4d82664ec84cffbb5682 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 08:38:35 -0700 Subject: [PATCH 10/43] repairs for interface build to succeed --- assignment-client/CMakeLists.txt | 3 ++ .../src/avatars/ScriptableAvatar.cpp | 2 ++ cmake/macros/IncludeHifiLibraryHeaders.cmake | 16 +++++++++ cmake/macros/SetupHifiProject.cmake | 6 ++-- cmake/modules/FindLibOVR.cmake | 10 ++++-- domain-server/CMakeLists.txt | 3 +- interface/CMakeLists.txt | 35 +++++-------------- interface/src/devices/CaraFaceTracker.cpp | 2 +- interface/src/renderer/JointState.h | 1 + interface/src/ui/overlays/Base3DOverlay.h | 2 ++ libraries/audio/src/InboundAudioStream.cpp | 2 ++ libraries/avatars/src/AvatarData.cpp | 2 +- libraries/avatars/src/HeadData.cpp | 1 + libraries/avatars/src/Referential.cpp | 2 +- libraries/fbx/src/FBXReader.cpp | 2 +- libraries/metavoxels/src/MetavoxelUtil.cpp | 2 ++ libraries/models/src/ModelItem.cpp | 9 +---- libraries/octree/src/OctreePacketData.cpp | 2 ++ libraries/octree/src/OctreePacketData.h | 1 - libraries/octree/src/OctreeQuery.cpp | 2 +- libraries/particles/src/Particle.cpp | 2 +- libraries/script-engine/src/Quat.cpp | 2 +- 22 files changed, 58 insertions(+), 51 deletions(-) create mode 100644 cmake/macros/IncludeHifiLibraryHeaders.cmake diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 2f3739485a..702c4a68ea 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -9,6 +9,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake include("${MACRO_DIR}/SetupHifiProject.cmake") setup_hifi_project(${TARGET_NAME} TRUE) +include(${MACRO_DIR}/IncludeGLM.cmake) +include_glm(${TARGET_NAME} "${ROOT_DIR}") + # link in the shared libraries include(${MACRO_DIR}/LinkHifiLibrary.cmake) link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") diff --git a/assignment-client/src/avatars/ScriptableAvatar.cpp b/assignment-client/src/avatars/ScriptableAvatar.cpp index 150e364ed7..0f721ac98c 100644 --- a/assignment-client/src/avatars/ScriptableAvatar.cpp +++ b/assignment-client/src/avatars/ScriptableAvatar.cpp @@ -11,6 +11,8 @@ #include +#include + #include "ScriptableAvatar.h" ScriptableAvatar::ScriptableAvatar(ScriptEngine* scriptEngine) : _scriptEngine(scriptEngine), _animation(NULL) { diff --git a/cmake/macros/IncludeHifiLibraryHeaders.cmake b/cmake/macros/IncludeHifiLibraryHeaders.cmake new file mode 100644 index 0000000000..aa7e1118c6 --- /dev/null +++ b/cmake/macros/IncludeHifiLibraryHeaders.cmake @@ -0,0 +1,16 @@ +# +# IncludeHifiLibraryHeaders.cmake +# cmake/macros +# +# Copyright 2014 High Fidelity, Inc. +# Created by Stephen Birarda on August 8, 2014 +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + +macro(include_hifi_library_headers LIBRARY ROOT_DIR) + + include_directories("${ROOT_DIR}/libraries/${LIBRARY}/src") + +endmacro(include_hifi_library_headers _library _root_dir) \ No newline at end of file diff --git a/cmake/macros/SetupHifiProject.cmake b/cmake/macros/SetupHifiProject.cmake index ec731859d4..281aa42650 100644 --- a/cmake/macros/SetupHifiProject.cmake +++ b/cmake/macros/SetupHifiProject.cmake @@ -26,9 +26,7 @@ macro(SETUP_HIFI_PROJECT TARGET INCLUDE_QT) add_executable(${TARGET} ${TARGET_SRCS} ${ARGN}) if (${INCLUDE_QT}) - find_package(Qt5Core REQUIRED) - qt5_use_modules(${TARGET} Core) + find_package(Qt5 COMPONENTS Core) + target_link_libraries(${TARGET} Qt5::Core) endif () - - target_link_libraries(${TARGET} ${QT_LIBRARIES}) endmacro() \ No newline at end of file diff --git a/cmake/modules/FindLibOVR.cmake b/cmake/modules/FindLibOVR.cmake index e90afe29e4..505fd90b51 100644 --- a/cmake/modules/FindLibOVR.cmake +++ b/cmake/modules/FindLibOVR.cmake @@ -29,6 +29,8 @@ include(SelectLibraryConfigurations) if (APPLE) find_library(LIBOVR_LIBRARY_DEBUG NAMES ovr PATH_SUFFIXES Lib/MacOS/Debug HINTS ${OCULUS_SEARCH_DIRS}) find_library(LIBOVR_LIBRARY_RELEASE NAMES ovr PATH_SUFFIXES Lib/MacOS/Release HINTS ${OCULUS_SEARCH_DIRS}) + find_library(ApplicationServices ApplicationServices) + find_library(IOKit IOKit) elseif (UNIX) find_library(UDEV_LIBRARY_RELEASE udev /usr/lib/x86_64-linux-gnu/) find_library(XINERAMA_LIBRARY_RELEASE Xinerama /usr/lib/x86_64-linux-gnu/) @@ -53,12 +55,16 @@ endif () select_library_configurations(LIBOVR) set(LIBOVR_LIBRARIES "${LIBOVR_LIBRARY}") -if (UNIX AND NOT APPLE) +if (APPLE) + set(LIBOVR_LIBRARIES "${LIBOVR_LIBRARIES}" ${IOKit} ${ApplicationServices}) +elseif (UNIX) set(LIBOVR_LIBRARIES "${LIBOVR_LIBRARIES}" "${UDEV_LIBRARY}" "${XINERAMA_LIBRARY}") endif () include(FindPackageHandleStandardArgs) -if (UNIX AND NOT APPLE) +if (APPLE) + find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES IOKit ApplicationServices) +elseif (UNIX) find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES UDEV_LIBRARY XINERAMA_LIBRARY) else () find_package_handle_standard_args(LIBOVR DEFAULT_MSG LIBOVR_INCLUDE_DIRS LIBOVR_SRC_DIR LIBOVR_LIBRARIES) diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 656760957d..4a030179e1 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -7,7 +7,6 @@ set(MACRO_DIR "${ROOT_DIR}/cmake/macros") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") include(${MACRO_DIR}/SetupHifiProject.cmake) - setup_hifi_project(${TARGET_NAME} TRUE) # remove and then copy the files for the webserver @@ -34,5 +33,5 @@ if (WIN32) add_definitions(-Dssize_t=long) endif () -find_package(Qt5 COMPONENTS Network) +find_package(Qt5 COMPONENTS Network Widgets) target_link_libraries(${TARGET_NAME} Qt5::Network) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index e624388408..f30fcc68ff 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -52,7 +52,7 @@ foreach(SUBDIR avatar devices renderer ui starfield location scripting voxels pa set(INTERFACE_SRCS ${INTERFACE_SRCS} "${SUBDIR_SRCS}") endforeach(SUBDIR) -# find_package(Qt5 COMPONENTS Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml UiTools) +find_package(Qt5 COMPONENTS Gui Multimedia Network OpenGL Script Svg WebKitWidgets) # grab the ui files in resources/ui file (GLOB_RECURSE QT_UI_FILES ui/*.ui) @@ -180,8 +180,8 @@ endif () include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes") target_link_libraries( - ${TARGET_NAME} - "${ZLIB_LIBRARIES}" + ${TARGET_NAME} "${ZLIB_LIBRARIES}" + Qt5::Gui Qt5::Network Qt5::Multimedia Qt5::OpenGL Qt5::Script Qt5::Svg Qt5::WebKitWidgets ) # assume we are using a Qt build without bearer management @@ -189,30 +189,11 @@ add_definitions(-DQT_NO_BEARERMANAGEMENT) if (APPLE) # link in required OS X frameworks and include the right GL headers - # find_library(AppKit AppKit) - # find_library(CoreAudio CoreAudio) - # find_library(CoreServices CoreServices) - # find_library(Carbon Carbon) - # find_library(Foundation Foundation) - # find_library(GLUT GLUT) - # find_library(OpenGL OpenGL) - # find_library(IOKit IOKit) - # find_library(QTKit QTKit) - # find_library(QuartzCore QuartzCore) - # - # target_link_libraries( - # ${TARGET_NAME} - # ${AppKit} - # ${CoreAudio} - # ${CoreServices} - # ${Carbon} - # ${Foundation} - # ${GLUT} - # ${OpenGL} - # ${IOKit} - # ${QTKit} - # ${QuartzCore} - # ) + find_library(CoreAudio CoreAudio) + find_library(GLUT GLUT) + find_library(OpenGL OpenGL) + + target_link_libraries(${TARGET_NAME} ${CoreAudio} ${GLUT} ${OpenGL}) # install command for OS X bundle INSTALL(TARGETS ${TARGET_NAME} diff --git a/interface/src/devices/CaraFaceTracker.cpp b/interface/src/devices/CaraFaceTracker.cpp index c7ae322ae8..27cf3b175b 100644 --- a/interface/src/devices/CaraFaceTracker.cpp +++ b/interface/src/devices/CaraFaceTracker.cpp @@ -10,7 +10,7 @@ // #include "CaraFaceTracker.h" -#include +#include //qt #include diff --git a/interface/src/renderer/JointState.h b/interface/src/renderer/JointState.h index 81591e816b..21961ba48c 100644 --- a/interface/src/renderer/JointState.h +++ b/interface/src/renderer/JointState.h @@ -16,6 +16,7 @@ #include #include +#include #include class AngularConstraint; diff --git a/interface/src/ui/overlays/Base3DOverlay.h b/interface/src/ui/overlays/Base3DOverlay.h index e2dcb82454..ffe73f0023 100644 --- a/interface/src/ui/overlays/Base3DOverlay.h +++ b/interface/src/ui/overlays/Base3DOverlay.h @@ -11,6 +11,8 @@ #ifndef hifi_Base3DOverlay_h #define hifi_Base3DOverlay_h +#include + #include "Overlay.h" class Base3DOverlay : public Overlay { diff --git a/libraries/audio/src/InboundAudioStream.cpp b/libraries/audio/src/InboundAudioStream.cpp index 0cd9be4a18..ba8d9481b5 100644 --- a/libraries/audio/src/InboundAudioStream.cpp +++ b/libraries/audio/src/InboundAudioStream.cpp @@ -9,6 +9,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include + #include "InboundAudioStream.h" #include "PacketHeaders.h" diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index 96a5f2425b..039ccae4e9 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/libraries/avatars/src/HeadData.cpp b/libraries/avatars/src/HeadData.cpp index b29277ddeb..538085af30 100644 --- a/libraries/avatars/src/HeadData.cpp +++ b/libraries/avatars/src/HeadData.cpp @@ -11,6 +11,7 @@ #include +#include #include #include "AvatarData.h" diff --git a/libraries/avatars/src/Referential.cpp b/libraries/avatars/src/Referential.cpp index a5a7e7e3e5..784ad3963c 100644 --- a/libraries/avatars/src/Referential.cpp +++ b/libraries/avatars/src/Referential.cpp @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include +#include #include "AvatarData.h" #include "Referential.h" diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index cf726800a1..1a152dc217 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -23,9 +23,9 @@ #include #include +#include #include #include -#include #include diff --git a/libraries/metavoxels/src/MetavoxelUtil.cpp b/libraries/metavoxels/src/MetavoxelUtil.cpp index e414c8ebb9..2b46330961 100644 --- a/libraries/metavoxels/src/MetavoxelUtil.cpp +++ b/libraries/metavoxels/src/MetavoxelUtil.cpp @@ -24,6 +24,8 @@ #include #include +#include + #include "MetavoxelUtil.h" #include "ScriptCache.h" #include "StreamUtils.h" diff --git a/libraries/models/src/ModelItem.cpp b/libraries/models/src/ModelItem.cpp index 2a3a88fb65..d6cd8aebc5 100644 --- a/libraries/models/src/ModelItem.cpp +++ b/libraries/models/src/ModelItem.cpp @@ -11,19 +11,12 @@ #include +#include #include #include -#include // usecTimestampNow() #include #include - -// This is not ideal, but adding script-engine as a linked library, will cause a circular reference -// I'm open to other potential solutions. Could we change cmake to allow libraries to reference each others -// headers, but not link to each other, this is essentially what this construct is doing, but would be -// better to add includes to the include path, but not link -#include "../../script-engine/src/ScriptEngine.h" - #include "ModelsScriptingInterface.h" #include "ModelItem.h" #include "ModelTree.h" diff --git a/libraries/octree/src/OctreePacketData.cpp b/libraries/octree/src/OctreePacketData.cpp index b54a87bef8..718f2534f8 100644 --- a/libraries/octree/src/OctreePacketData.cpp +++ b/libraries/octree/src/OctreePacketData.cpp @@ -9,7 +9,9 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include #include + #include "OctreePacketData.h" bool OctreePacketData::_debug = false; diff --git a/libraries/octree/src/OctreePacketData.h b/libraries/octree/src/OctreePacketData.h index d704923a11..9a6ebfa9ff 100644 --- a/libraries/octree/src/OctreePacketData.h +++ b/libraries/octree/src/OctreePacketData.h @@ -22,7 +22,6 @@ #ifndef hifi_OctreePacketData_h #define hifi_OctreePacketData_h -#include #include "OctreeConstants.h" #include "OctreeElement.h" diff --git a/libraries/octree/src/OctreeQuery.cpp b/libraries/octree/src/OctreeQuery.cpp index 687dd18037..94d9bf458e 100644 --- a/libraries/octree/src/OctreeQuery.cpp +++ b/libraries/octree/src/OctreeQuery.cpp @@ -9,7 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include +#include #include "OctreeConstants.h" #include "OctreeQuery.h" diff --git a/libraries/particles/src/Particle.cpp b/libraries/particles/src/Particle.cpp index 5fffefd8b1..fef2b95fdc 100644 --- a/libraries/particles/src/Particle.cpp +++ b/libraries/particles/src/Particle.cpp @@ -13,7 +13,7 @@ #include #include -#include // usecTimestampNow() +#include #include #include diff --git a/libraries/script-engine/src/Quat.cpp b/libraries/script-engine/src/Quat.cpp index 66281883f0..5985858026 100644 --- a/libraries/script-engine/src/Quat.cpp +++ b/libraries/script-engine/src/Quat.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include "Quat.h" From 107cbc3f87205815a6ec97dd035a7538da2d523b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 09:22:19 -0700 Subject: [PATCH 11/43] more simplification of hifi macros to find libraries --- CMakeLists.txt | 10 ++++++++ assignment-client/CMakeLists.txt | 37 +++++++++++------------------- cmake/macros/IncludeGLM.cmake | 4 ++-- cmake/macros/LinkHifiLibrary.cmake | 10 ++++---- domain-server/CMakeLists.txt | 14 +++-------- 5 files changed, 35 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 578c36841d..9f033e5184 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,16 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) +set(HIFI_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries") +set(MACRO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros") +# setup for find modules +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/") + +file(GLOB HIFI_CUSTOM_MACROS "cmake/macros/*.cmake") +foreach(CUSTOM_MACRO ${HIFI_CUSTOM_MACROS}) + include(${CUSTOM_MACRO}) +endforeach() + # targets on all platforms add_subdirectory(assignment-client) add_subdirectory(domain-server) diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 702c4a68ea..2d7d43227a 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -1,32 +1,23 @@ set(TARGET_NAME assignment-client) -set(ROOT_DIR ..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") - -include("${MACRO_DIR}/SetupHifiProject.cmake") setup_hifi_project(${TARGET_NAME} TRUE) -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm(${TARGET_NAME}) # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(audio ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(avatars ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(particles ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(models ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(script-engine ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(embedded-webserver ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_library(shared ${TARGET_NAME}) +link_hifi_library(audio ${TARGET_NAME}) +link_hifi_library(avatars ${TARGET_NAME}) +link_hifi_library(octree ${TARGET_NAME}) +link_hifi_library(voxels ${TARGET_NAME}) +link_hifi_library(fbx ${TARGET_NAME}) +link_hifi_library(particles ${TARGET_NAME}) +link_hifi_library(models ${TARGET_NAME}) +link_hifi_library(metavoxels ${TARGET_NAME}) +link_hifi_library(networking ${TARGET_NAME}) +link_hifi_library(animation ${TARGET_NAME}) +link_hifi_library(script-engine ${TARGET_NAME}) +link_hifi_library(embedded-webserver ${TARGET_NAME}) if (UNIX) target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} ${CMAKE_DL_LIBS}) diff --git a/cmake/macros/IncludeGLM.cmake b/cmake/macros/IncludeGLM.cmake index a31324993e..ec7816770f 100644 --- a/cmake/macros/IncludeGLM.cmake +++ b/cmake/macros/IncludeGLM.cmake @@ -7,7 +7,7 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(INCLUDE_GLM TARGET ROOT_DIR) +macro(INCLUDE_GLM TARGET) find_package(GLM REQUIRED) include_directories("${GLM_INCLUDE_DIRS}") @@ -16,4 +16,4 @@ macro(INCLUDE_GLM TARGET ROOT_DIR) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${GLM_INCLUDE_DIRS}") endif () -endmacro(INCLUDE_GLM _target _root_dir) \ No newline at end of file +endmacro(INCLUDE_GLM _target) \ No newline at end of file diff --git a/cmake/macros/LinkHifiLibrary.cmake b/cmake/macros/LinkHifiLibrary.cmake index 227ddf066a..95af4c6fd0 100644 --- a/cmake/macros/LinkHifiLibrary.cmake +++ b/cmake/macros/LinkHifiLibrary.cmake @@ -7,13 +7,15 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(LINK_HIFI_LIBRARY LIBRARY TARGET ROOT_DIR) +macro(LINK_HIFI_LIBRARY LIBRARY TARGET) + + file(RELATIVE_PATH RELATIVE_LIBRARY_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}/${LIBRARY}") if (NOT TARGET ${LIBRARY}) - add_subdirectory("${ROOT_DIR}/libraries/${LIBRARY}" "${ROOT_DIR}/libraries/${LIBRARY}") + add_subdirectory(${RELATIVE_LIBRARY_PATH} ${RELATIVE_LIBRARY_PATH}) endif () - include_directories("${ROOT_DIR}/libraries/${LIBRARY}/src") + include_directories("${HIFI_LIBRARY_DIR}/${LIBRARY}/src") add_dependencies(${TARGET} ${LIBRARY}) @@ -25,4 +27,4 @@ macro(LINK_HIFI_LIBRARY LIBRARY TARGET ROOT_DIR) target_link_libraries(${TARGET} ${LIBRARY}) endif () -endmacro(LINK_HIFI_LIBRARY _library _target _root_dir) \ No newline at end of file +endmacro(LINK_HIFI_LIBRARY _library _target) \ No newline at end of file diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 4a030179e1..e98cee7437 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -1,12 +1,5 @@ set(TARGET_NAME domain-server) -set(ROOT_DIR ..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) # remove and then copy the files for the webserver @@ -19,10 +12,9 @@ add_custom_command(TARGET ${TARGET_NAME} POST_BUILD $/resources/web) # link the shared hifi library -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(embedded-webserver ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_library(networking ${TARGET_NAME}) +link_hifi_library(shared ${TARGET_NAME}) +link_hifi_library(embedded-webserver ${TARGET_NAME}) IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) From 87cf262b9e49f48ca760f3b34f4d8108fbb4a78f Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 09:38:17 -0700 Subject: [PATCH 12/43] get to successful cmake after library link macro changes --- assignment-client/CMakeLists.txt | 14 +----------- cmake/macros/LinkHifiLibraries.cmake | 34 ++++++++++++++++++++++++++++ cmake/macros/LinkHifiLibrary.cmake | 30 ------------------------ domain-server/CMakeLists.txt | 4 +--- interface/CMakeLists.txt | 16 +------------ libraries/audio/CMakeLists.txt | 16 +------------ libraries/metavoxels/CMakeLists.txt | 12 +--------- libraries/octree/CMakeLists.txt | 12 +--------- libraries/shared/CMakeLists.txt | 19 ---------------- tests/audio/CMakeLists.txt | 22 +----------------- tests/jitter/CMakeLists.txt | 24 +------------------- tests/metavoxels/CMakeLists.txt | 17 +------------- tests/networking/CMakeLists.txt | 24 +------------------- tests/octree/CMakeLists.txt | 29 +----------------------- tests/physics/CMakeLists.txt | 27 +--------------------- tests/shared/CMakeLists.txt | 28 +---------------------- tools/bitstream2json/CMakeLists.txt | 25 +------------------- tools/json2bitstream/CMakeLists.txt | 25 +------------------- voxel-edit/CMakeLists.txt | 32 -------------------------- 19 files changed, 49 insertions(+), 361 deletions(-) create mode 100644 cmake/macros/LinkHifiLibraries.cmake delete mode 100644 cmake/macros/LinkHifiLibrary.cmake diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 2d7d43227a..628e473853 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -5,19 +5,7 @@ setup_hifi_project(${TARGET_NAME} TRUE) include_glm(${TARGET_NAME}) # link in the shared libraries -link_hifi_library(shared ${TARGET_NAME}) -link_hifi_library(audio ${TARGET_NAME}) -link_hifi_library(avatars ${TARGET_NAME}) -link_hifi_library(octree ${TARGET_NAME}) -link_hifi_library(voxels ${TARGET_NAME}) -link_hifi_library(fbx ${TARGET_NAME}) -link_hifi_library(particles ${TARGET_NAME}) -link_hifi_library(models ${TARGET_NAME}) -link_hifi_library(metavoxels ${TARGET_NAME}) -link_hifi_library(networking ${TARGET_NAME}) -link_hifi_library(animation ${TARGET_NAME}) -link_hifi_library(script-engine ${TARGET_NAME}) -link_hifi_library(embedded-webserver ${TARGET_NAME}) +link_hifi_libraries(${TARGET_NAME} audio avatars octree voxels fbx particles models metavoxels networking animation script-engine embedded-webserver) if (UNIX) target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} ${CMAKE_DL_LIBS}) diff --git a/cmake/macros/LinkHifiLibraries.cmake b/cmake/macros/LinkHifiLibraries.cmake new file mode 100644 index 0000000000..cf7499c763 --- /dev/null +++ b/cmake/macros/LinkHifiLibraries.cmake @@ -0,0 +1,34 @@ +# +# LinkHifiLibrary.cmake +# +# Copyright 2013 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + +macro(LINK_HIFI_LIBRARIES TARGET LIBRARIES) + + file(RELATIVE_PATH RELATIVE_LIBRARY_DIR_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}") + + foreach(HIFI_LIBRARY ${LIBRARIES}) + + if (NOT TARGET ${HIFI_LIBRARY}) + add_subdirectory("${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}" "${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}") + endif () + + include_directories("${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src") + + add_dependencies(${TARGET} ${HIFI_LIBRARY}) + + get_target_property(LINKED_TARGET_DEPENDENCY_LIBRARIES ${HIFI_LIBRARY} DEPENDENCY_LIBRARIES) + + if (LINKED_TARGET_DEPENDENCY_LIBRARIES) + target_link_libraries(${TARGET} ${HIFI_LIBRARY} ${LINKED_TARGET_DEPENDENCY_LIBRARIES}) + else () + target_link_libraries(${TARGET} ${HIFI_LIBRARY}) + endif () + + endforeach() + +endmacro(LINK_HIFI_LIBRARIES _target _libraries) \ No newline at end of file diff --git a/cmake/macros/LinkHifiLibrary.cmake b/cmake/macros/LinkHifiLibrary.cmake deleted file mode 100644 index 95af4c6fd0..0000000000 --- a/cmake/macros/LinkHifiLibrary.cmake +++ /dev/null @@ -1,30 +0,0 @@ -# -# LinkHifiLibrary.cmake -# -# Copyright 2013 High Fidelity, Inc. -# -# Distributed under the Apache License, Version 2.0. -# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -# - -macro(LINK_HIFI_LIBRARY LIBRARY TARGET) - - file(RELATIVE_PATH RELATIVE_LIBRARY_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}/${LIBRARY}") - - if (NOT TARGET ${LIBRARY}) - add_subdirectory(${RELATIVE_LIBRARY_PATH} ${RELATIVE_LIBRARY_PATH}) - endif () - - include_directories("${HIFI_LIBRARY_DIR}/${LIBRARY}/src") - - add_dependencies(${TARGET} ${LIBRARY}) - - get_target_property(LINKED_TARGET_DEPENDENCY_LIBRARIES ${LIBRARY} DEPENDENCY_LIBRARIES) - - if (LINKED_TARGET_DEPENDENCY_LIBRARIES) - target_link_libraries(${TARGET} ${LIBRARY} ${LINKED_TARGET_DEPENDENCY_LIBRARIES}) - else () - target_link_libraries(${TARGET} ${LIBRARY}) - endif () - -endmacro(LINK_HIFI_LIBRARY _library _target) \ No newline at end of file diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index e98cee7437..ae130af5ed 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -12,9 +12,7 @@ add_custom_command(TARGET ${TARGET_NAME} POST_BUILD $/resources/web) # link the shared hifi library -link_hifi_library(networking ${TARGET_NAME}) -link_hifi_library(shared ${TARGET_NAME}) -link_hifi_library(embedded-webserver ${TARGET_NAME}) +link_hifi_libraries(${TARGET_NAME} embedded-webserver networking shared) IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index f30fcc68ff..ed280846fe 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -97,22 +97,8 @@ endif() # create the executable, make it a bundle on OS X add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM}) -# link in the hifi shared library -include(${MACRO_DIR}/LinkHifiLibrary.cmake) - # link required hifi libraries -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(particles ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(models ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(avatars ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(audio ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(script-engine ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx metavoxels networking particles models avatars audio animation script-engine) # find any optional and required libraries find_package(Faceplus) diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index ace5f9292c..73d15f0b73 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -1,24 +1,10 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME audio) -find_package(Qt5 COMPONENTS Script) -include_directories(SYSTEM "${Qt5Script_INCLUDE_DIRS}") - -# set up the external glm library -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} networking shared) find_package(Qt5 COMPONENTS Network) diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index 799a549a3b..88b74194ac 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -1,22 +1,12 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME metavoxels) -include(${MACRO_DIR}/AutoMTC.cmake) auto_mtc(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME} "${AUTOMTC_SRC}") # link in the networking library -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} networking) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") find_package(Qt5 COMPONENTS Network Script Widgets) diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index d0beade108..efdb1bc70a 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -1,20 +1,10 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME octree) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared networking) # link ZLIB find_package(ZLIB) diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 6badb10f8e..b8e34739b8 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -1,25 +1,6 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - set(TARGET_NAME shared) -project(${TARGET_NAME}) - -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -# include GLM -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -# link required libraries on UNIX -if (APPLE) - find_library(CoreServices CoreServices) - set(DEPENDENCY_LIBRARIES ${CoreServices}) -elseif (UNIX) - find_package(Threads REQUIRED) - set(DEPENDENCY_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") -endif () - find_package(Qt5 COMPONENTS Network Widgets) # bubble up the libraries we are dependent on and link them to ourselves diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index b7375a0086..15da1afaa1 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -1,32 +1,12 @@ set(TARGET_NAME audio-tests) -set(ROOT_DIR ../..) -set(MACRO_DIR ${ROOT_DIR}/cmake/macros) - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -#find_package(Qt5Network REQUIRED) -#find_package(Qt5Script REQUIRED) -#find_package(Qt5Widgets REQUIRED) - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) -include(${MACRO_DIR}/AutoMTC.cmake) -auto_mtc(${TARGET_NAME} ${ROOT_DIR}) - -#qt5_use_modules(${TARGET_NAME} Network Script Widgets) - #include glm -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} ${ROOT_DIR}) # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(audio ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(networking ${TARGET_NAME} ${ROOT_DIR}) +link_hifi_libraries(${TARGET_NAME} shared audio networking) IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) diff --git a/tests/jitter/CMakeLists.txt b/tests/jitter/CMakeLists.txt index 8000e4af50..3b1d544690 100644 --- a/tests/jitter/CMakeLists.txt +++ b/tests/jitter/CMakeLists.txt @@ -1,31 +1,9 @@ set(TARGET_NAME jitter-tests) -set(ROOT_DIR ../..) -set(MACRO_DIR ${ROOT_DIR}/cmake/macros) - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -#find_package(Qt5Network REQUIRED) -#find_package(Qt5Script REQUIRED) -#find_package(Qt5Widgets REQUIRED) - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) -#include(${MACRO_DIR}/AutoMTC.cmake) -#auto_mtc(${TARGET_NAME} ${ROOT_DIR}) - -#qt5_use_modules(${TARGET_NAME} Network Script Widgets) - -#include glm - because it's a dependency of shared utils... -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} ${ROOT_DIR}) - # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(networking ${TARGET_NAME} ${ROOT_DIR}) +link_hifi_libraries(${TARGET_NAME} shared networking) IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) diff --git a/tests/metavoxels/CMakeLists.txt b/tests/metavoxels/CMakeLists.txt index f4c0695362..233988f849 100644 --- a/tests/metavoxels/CMakeLists.txt +++ b/tests/metavoxels/CMakeLists.txt @@ -1,28 +1,13 @@ set(TARGET_NAME metavoxel-tests) -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - find_package(Qt5 COMPONENTS Network Script Widgets) -include(${MACRO_DIR}/AutoMTC.cmake) auto_mtc(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE "${AUTOMTC_SRC}") -#include glm -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} metavoxels networking shared) IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) diff --git a/tests/networking/CMakeLists.txt b/tests/networking/CMakeLists.txt index 64b5f273d1..819229d28f 100644 --- a/tests/networking/CMakeLists.txt +++ b/tests/networking/CMakeLists.txt @@ -1,31 +1,9 @@ set(TARGET_NAME networking-tests) -set(ROOT_DIR ../..) -set(MACRO_DIR ${ROOT_DIR}/cmake/macros) - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -#find_package(Qt5Network REQUIRED) -#find_package(Qt5Script REQUIRED) -#find_package(Qt5Widgets REQUIRED) - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) -include(${MACRO_DIR}/AutoMTC.cmake) -auto_mtc(${TARGET_NAME} ${ROOT_DIR}) - -#qt5_use_modules(${TARGET_NAME} Network Script Widgets) - -#include glm -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} ${ROOT_DIR}) - # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(networking ${TARGET_NAME} ${ROOT_DIR}) +link_hifi_libraries(${TARGET_NAME} shared networking) IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index c7a6500b6d..a4888b2c66 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -1,36 +1,9 @@ set(TARGET_NAME octree-tests) -set(ROOT_DIR ../..) -set(MACRO_DIR ${ROOT_DIR}/cmake/macros) - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -find_package(Qt5Network REQUIRED) -find_package(Qt5Script REQUIRED) -find_package(Qt5Widgets REQUIRED) - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) -include(${MACRO_DIR}/AutoMTC.cmake) -auto_mtc(${TARGET_NAME} ${ROOT_DIR}) - -qt5_use_modules(${TARGET_NAME} Network Script Widgets) - -#include glm -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} ${ROOT_DIR}) - # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(models ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(octree ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(audio ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(networking ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(animation ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(fbx ${TARGET_NAME} ${ROOT_DIR}) -link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) +link_hifi_libraries(${TARGET_NAME} octree) IF (WIN32) # add a definition for ssize_t so that windows doesn't bail diff --git a/tests/physics/CMakeLists.txt b/tests/physics/CMakeLists.txt index 643d318f7d..2161723619 100644 --- a/tests/physics/CMakeLists.txt +++ b/tests/physics/CMakeLists.txt @@ -1,32 +1,7 @@ set(TARGET_NAME physics-tests) -set(ROOT_DIR ../..) -set(MACRO_DIR ${ROOT_DIR}/cmake/macros) - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -#find_package(Qt5Network REQUIRED) -#find_package(Qt5Script REQUIRED) -#find_package(Qt5Widgets REQUIRED) - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) -include(${MACRO_DIR}/AutoMTC.cmake) -auto_mtc(${TARGET_NAME} ${ROOT_DIR}) - -#qt5_use_modules(${TARGET_NAME} Network Script Widgets) - -#include glm -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} ${ROOT_DIR}) - # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) - -IF (WIN32) - #target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) +link_hifi_libraries(${TARGET_NAME} shared) diff --git a/tests/shared/CMakeLists.txt b/tests/shared/CMakeLists.txt index 0785314d36..bea8448f5e 100644 --- a/tests/shared/CMakeLists.txt +++ b/tests/shared/CMakeLists.txt @@ -1,32 +1,6 @@ set(TARGET_NAME shared-tests) -set(ROOT_DIR ../..) -set(MACRO_DIR ${ROOT_DIR}/cmake/macros) - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -#find_package(Qt5Network REQUIRED) -#find_package(Qt5Script REQUIRED) -#find_package(Qt5Widgets REQUIRED) - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) -include(${MACRO_DIR}/AutoMTC.cmake) -auto_mtc(${TARGET_NAME} ${ROOT_DIR}) - -#qt5_use_modules(${TARGET_NAME} Network Script Widgets) - -#include glm -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} ${ROOT_DIR}) - # link in the shared libraries -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} ${ROOT_DIR}) - -IF (WIN32) - #target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - +link_hifi_libraries(${TARGET_NAME} shared) diff --git a/tools/bitstream2json/CMakeLists.txt b/tools/bitstream2json/CMakeLists.txt index 576406e787..3b3a65c259 100644 --- a/tools/bitstream2json/CMakeLists.txt +++ b/tools/bitstream2json/CMakeLists.txt @@ -1,25 +1,2 @@ set(TARGET_NAME bitstream2json) - -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -find_package(Qt5 COMPONENTS Network Script Widgets) - -include(${MACRO_DIR}/SetupHifiProject.cmake) -setup_hifi_project(${TARGET_NAME} TRUE) - -link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") - -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - -target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script) +setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file diff --git a/tools/json2bitstream/CMakeLists.txt b/tools/json2bitstream/CMakeLists.txt index 5ff4673298..452f845356 100644 --- a/tools/json2bitstream/CMakeLists.txt +++ b/tools/json2bitstream/CMakeLists.txt @@ -1,25 +1,2 @@ set(TARGET_NAME json2bitstream) - -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - -find_package(Qt5 COMPONENTS Network Script Widgets) - -include(${MACRO_DIR}/SetupHifiProject.cmake) -setup_hifi_project(${TARGET_NAME} TRUE) - -link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") - -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - -target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script) +setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file diff --git a/voxel-edit/CMakeLists.txt b/voxel-edit/CMakeLists.txt index 006dfb0599..8c315c92a0 100644 --- a/voxel-edit/CMakeLists.txt +++ b/voxel-edit/CMakeLists.txt @@ -1,39 +1,7 @@ set(TARGET_NAME voxel-edit) -set(ROOT_DIR ..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") - -# set up the external glm library -include(${MACRO_DIR}/IncludeGLM.cmake) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -find_package(Qt5Script REQUIRED) - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) -# link in the shared library -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") - -# link in the hifi octree library -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") - -# link in the hifi voxels library -link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") - -# link in the hifi networking library -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") - -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - -target_link_libraries(${TARGET_NAME} Qt5::Script) - # add a definition for ssize_t so that windows doesn't bail if (WIN32) add_definitions(-Dssize_t=long) From 93b6f167f5d5b5ee5fd5aeae96b9b85334aefc0c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 09:51:20 -0700 Subject: [PATCH 13/43] change more CMakeLists to use simplified hifi library linker --- cmake/macros/LinkHifiLibraries.cmake | 7 ++++--- libraries/animation/CMakeLists.txt | 11 +---------- libraries/avatars/CMakeLists.txt | 15 +-------------- libraries/fbx/CMakeLists.txt | 14 +------------- libraries/models/CMakeLists.txt | 20 +------------------- libraries/networking/CMakeLists.txt | 6 ++---- libraries/particles/CMakeLists.txt | 15 +-------------- libraries/script-engine/CMakeLists.txt | 17 +---------------- libraries/voxels/CMakeLists.txt | 16 ++-------------- 9 files changed, 14 insertions(+), 107 deletions(-) diff --git a/cmake/macros/LinkHifiLibraries.cmake b/cmake/macros/LinkHifiLibraries.cmake index cf7499c763..4c6e2c3215 100644 --- a/cmake/macros/LinkHifiLibraries.cmake +++ b/cmake/macros/LinkHifiLibraries.cmake @@ -7,12 +7,13 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(LINK_HIFI_LIBRARIES TARGET LIBRARIES) +macro(LINK_HIFI_LIBRARIES TARGET) file(RELATIVE_PATH RELATIVE_LIBRARY_DIR_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}") - foreach(HIFI_LIBRARY ${LIBRARIES}) - + set(LIBRARIES_TO_LINK ${ARGN}) + + foreach(HIFI_LIBRARY ${LIBRARIES_TO_LINK}) if (NOT TARGET ${HIFI_LIBRARY}) add_subdirectory("${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}" "${RELATIVE_LIBRARY_DIR_PATH}/${HIFI_LIBRARY}") endif () diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 7891c65dcc..186067ba3f 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -1,17 +1,8 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME animation) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared fbx) find_package(Qt5 COMPONENTS Network Script) diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index 1300a2e733..10507f7836 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -1,23 +1,10 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME avatars) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") - -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared octree voxels networking) find_package(Qt5 COMPONENTS Network Script) diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index ba51fe2e06..3f6a969cbc 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -1,22 +1,10 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME fbx) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared networking octree voxels) # link ZLIB find_package(ZLIB) diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index 8128741ef6..20f6ef1ef8 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -1,28 +1,10 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME models) -find_package(Qt5Widgets REQUIRED) - -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") - -# for streamable -link_hifi_library(metavoxels ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) find_package(Qt5 COMPONENTS Network Script) diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 7bd210623b..f41d410ce8 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -1,11 +1,9 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - set(TARGET_NAME networking) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) +link_hifi_libraries(${TARGET_NAME} shared) + find_package(Qt5 COMPONENTS Network) # set a property indicating the libraries we are dependent on and link them to ourselves diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index 54398ac252..0f8a555cb5 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -1,23 +1,10 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME particles) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) find_package(Qt5 COMPONENTS Gui Network Script) diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index 1b0199977f..f9b4b7d60f 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -1,25 +1,10 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME script-engine) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(voxels ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(fbx ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(particles ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(models ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(animation ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx particles models animation) find_package(Qt5 COMPONENTS Gui Network Script Widgets) diff --git a/libraries/voxels/CMakeLists.txt b/libraries/voxels/CMakeLists.txt index 2ae35da2c0..c421f6514f 100644 --- a/libraries/voxels/CMakeLists.txt +++ b/libraries/voxels/CMakeLists.txt @@ -1,26 +1,14 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME voxels) -find_package(Qt5 COMPONENTS Widgets Script) - -include(${MACRO_DIR}/SetupHifiLibrary.cmake) setup_hifi_library(${TARGET_NAME}) -include(${MACRO_DIR}/IncludeGLM.cmake) include_glm(${TARGET_NAME} "${ROOT_DIR}") -include(${MACRO_DIR}/LinkHifiLibrary.cmake) -link_hifi_library(shared ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(octree ${TARGET_NAME} "${ROOT_DIR}") -link_hifi_library(networking ${TARGET_NAME} "${ROOT_DIR}") +link_hifi_libraries(${TARGET_NAME} shared octree networking) # link ZLIB find_package(ZLIB) +find_package(Qt5 COMPONENTS Widgets Script) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets Qt5::Script) From 1a71d655b9de1974696574e69347284b035d4007 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 09:58:27 -0700 Subject: [PATCH 14/43] more cmake cleanup to remove ROOT_DIR passing --- CMakeLists.txt | 2 ++ assignment-client/CMakeLists.txt | 5 ++++- cmake/macros/AutoMTC.cmake | 2 +- cmake/macros/IncludeHifiLibraryHeaders.cmake | 4 ++-- interface/CMakeLists.txt | 7 ------- libraries/metavoxels/CMakeLists.txt | 2 +- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f033e5184..fb54bcbd8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,8 +44,10 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) +set(ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(HIFI_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries") set(MACRO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros") + # setup for find modules set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/") diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 628e473853..fd11be5122 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -5,7 +5,10 @@ setup_hifi_project(${TARGET_NAME} TRUE) include_glm(${TARGET_NAME}) # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} audio avatars octree voxels fbx particles models metavoxels networking animation script-engine embedded-webserver) +link_hifi_libraries(${TARGET_NAME} + audio avatars octree voxels fbx particles models metavoxels + networking animation shared script-engine embedded-webserver +) if (UNIX) target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} ${CMAKE_DL_LIBS}) diff --git a/cmake/macros/AutoMTC.cmake b/cmake/macros/AutoMTC.cmake index 6f0216de7f..0e376fc176 100644 --- a/cmake/macros/AutoMTC.cmake +++ b/cmake/macros/AutoMTC.cmake @@ -8,7 +8,7 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(AUTO_MTC TARGET ROOT_DIR) +macro(AUTO_MTC TARGET) set(AUTOMTC_SRC ${TARGET}_automtc.cpp) file(GLOB INCLUDE_FILES src/*.h) diff --git a/cmake/macros/IncludeHifiLibraryHeaders.cmake b/cmake/macros/IncludeHifiLibraryHeaders.cmake index aa7e1118c6..7ac31f5259 100644 --- a/cmake/macros/IncludeHifiLibraryHeaders.cmake +++ b/cmake/macros/IncludeHifiLibraryHeaders.cmake @@ -9,8 +9,8 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(include_hifi_library_headers LIBRARY ROOT_DIR) +macro(include_hifi_library_headers LIBRARY) - include_directories("${ROOT_DIR}/libraries/${LIBRARY}/src") + include_directories("${HIFI_LIBRARY_DIR}/libraries/${LIBRARY}/src") endmacro(include_hifi_library_headers _library _root_dir) \ No newline at end of file diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index ed280846fe..cb2065e256 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -1,12 +1,6 @@ -set(ROOT_DIR ..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - set(TARGET_NAME interface) project(${TARGET_NAME}) -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules/") - # set a default root dir for each of our optional externals if it was not passed set(OPTIONAL_EXTERNALS "faceplus" "faceshift" "oculus" "priovr" "sixense" "visage" "leapmotion" "rtmidi" "qxmpp") foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) @@ -38,7 +32,6 @@ elseif (WIN32) endif () # set up the external glm library -include("${MACRO_DIR}/IncludeGLM.cmake") include_glm(${TARGET_NAME} "${ROOT_DIR}") # create the InterfaceConfig.h file based on GL_HEADERS above diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index 88b74194ac..29f7f85f9c 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -5,7 +5,7 @@ auto_mtc(${TARGET_NAME} "${ROOT_DIR}") setup_hifi_library(${TARGET_NAME} "${AUTOMTC_SRC}") # link in the networking library -link_hifi_libraries(${TARGET_NAME} networking) +link_hifi_libraries(${TARGET_NAME} shared networking) include_glm(${TARGET_NAME} "${ROOT_DIR}") From c63e886444294bdfaf2c12c8082a6df0c0b5c0a5 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 10:04:34 -0700 Subject: [PATCH 15/43] don't look backwards for fbx header from avatars library --- cmake/macros/IncludeHifiLibraryHeaders.cmake | 4 +--- libraries/avatars/CMakeLists.txt | 1 + libraries/avatars/src/HeadData.cpp | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cmake/macros/IncludeHifiLibraryHeaders.cmake b/cmake/macros/IncludeHifiLibraryHeaders.cmake index 7ac31f5259..913d1e1181 100644 --- a/cmake/macros/IncludeHifiLibraryHeaders.cmake +++ b/cmake/macros/IncludeHifiLibraryHeaders.cmake @@ -10,7 +10,5 @@ # macro(include_hifi_library_headers LIBRARY) - - include_directories("${HIFI_LIBRARY_DIR}/libraries/${LIBRARY}/src") - + include_directories("${HIFI_LIBRARY_DIR}/${LIBRARY}/src") endmacro(include_hifi_library_headers _library _root_dir) \ No newline at end of file diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index 10507f7836..138b218381 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -5,6 +5,7 @@ setup_hifi_library(${TARGET_NAME}) include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree voxels networking) +include_hifi_library_headers(fbx) find_package(Qt5 COMPONENTS Network Script) diff --git a/libraries/avatars/src/HeadData.cpp b/libraries/avatars/src/HeadData.cpp index 538085af30..2bdb203034 100644 --- a/libraries/avatars/src/HeadData.cpp +++ b/libraries/avatars/src/HeadData.cpp @@ -11,14 +11,13 @@ #include +#include #include #include #include "AvatarData.h" #include "HeadData.h" -#include "../fbx/src/FBXReader.h" - HeadData::HeadData(AvatarData* owningAvatar) : _baseYaw(0.0f), _basePitch(0.0f), From a75a3f943482f5886ef87187978428cce12f66fc Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 10:06:56 -0700 Subject: [PATCH 16/43] don't look backwards for script-engine headers from particles library --- libraries/particles/CMakeLists.txt | 1 + libraries/particles/src/Particle.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index 0f8a555cb5..0ab11e3f82 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -5,6 +5,7 @@ setup_hifi_library(${TARGET_NAME}) include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) +include_hifi_library_headers(script-engine) find_package(Qt5 COMPONENTS Gui Network Script) diff --git a/libraries/particles/src/Particle.cpp b/libraries/particles/src/Particle.cpp index fef2b95fdc..5db285ebeb 100644 --- a/libraries/particles/src/Particle.cpp +++ b/libraries/particles/src/Particle.cpp @@ -22,7 +22,7 @@ // I'm open to other potential solutions. Could we change cmake to allow libraries to reference each others // headers, but not link to each other, this is essentially what this construct is doing, but would be // better to add includes to the include path, but not link -#include "../../script-engine/src/ScriptEngine.h" +#include #include "ParticlesScriptingInterface.h" #include "Particle.h" From 17df6484d426666e4e22b053f85299a4a02aa26d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 10:14:31 -0700 Subject: [PATCH 17/43] remove ssize_t and replace with size_t or int where appropriate --- assignment-client/CMakeLists.txt | 5 ----- assignment-client/src/Agent.cpp | 2 +- domain-server/CMakeLists.txt | 5 ----- interface/CMakeLists.txt | 3 --- interface/src/voxels/OctreePacketProcessor.cpp | 2 +- libraries/animation/CMakeLists.txt | 5 ----- libraries/audio/CMakeLists.txt | 5 ----- libraries/avatars/CMakeLists.txt | 5 ----- libraries/fbx/CMakeLists.txt | 5 ----- libraries/metavoxels/CMakeLists.txt | 7 +------ libraries/models/CMakeLists.txt | 5 ----- libraries/models/src/ModelEditPacketSender.cpp | 2 +- libraries/models/src/ModelEditPacketSender.h | 2 +- libraries/models/src/ModelItem.cpp | 2 +- libraries/models/src/ModelItem.h | 2 +- libraries/networking/CMakeLists.txt | 5 ----- libraries/networking/src/PacketSender.h | 4 ---- libraries/networking/src/ReceivedPacketProcessor.h | 4 ---- libraries/octree/CMakeLists.txt | 5 ----- libraries/octree/src/EditPacketBuffer.cpp | 2 +- libraries/octree/src/EditPacketBuffer.h | 4 ++-- libraries/octree/src/JurisdictionListener.cpp | 2 +- libraries/octree/src/JurisdictionListener.h | 4 ---- libraries/octree/src/JurisdictionSender.cpp | 2 +- libraries/octree/src/OctreeEditPacketSender.cpp | 8 ++++---- libraries/octree/src/OctreeEditPacketSender.h | 10 +++++----- libraries/particles/CMakeLists.txt | 7 +------ libraries/particles/src/Particle.cpp | 2 +- libraries/particles/src/Particle.h | 2 +- libraries/particles/src/ParticleEditPacketSender.cpp | 2 +- libraries/particles/src/ParticleEditPacketSender.h | 2 +- libraries/script-engine/CMakeLists.txt | 7 +------ libraries/voxels/CMakeLists.txt | 5 ----- libraries/voxels/src/VoxelEditPacketSender.h | 2 +- tests/octree/CMakeLists.txt | 8 +------- voxel-edit/CMakeLists.txt | 7 +------ 36 files changed, 30 insertions(+), 121 deletions(-) diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index fd11be5122..d4281eb185 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -20,8 +20,3 @@ ENDIF(WIN32) find_package(Qt5 COMPONENTS Gui Network Script Widgets) target_link_libraries(${TARGET_NAME} Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/assignment-client/src/Agent.cpp b/assignment-client/src/Agent.cpp index dbb1620252..09496f0179 100644 --- a/assignment-client/src/Agent.cpp +++ b/assignment-client/src/Agent.cpp @@ -115,7 +115,7 @@ void Agent::readPendingDatagrams() { sourceNode->setLastHeardMicrostamp(usecTimestampNow()); QByteArray mutablePacket = receivedPacket; - ssize_t messageLength = mutablePacket.size(); + int messageLength = mutablePacket.size(); if (datagramPacketType == PacketTypeOctreeStats) { diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index ae130af5ed..c04ba33a5d 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -18,10 +18,5 @@ IF (WIN32) target_link_libraries(${TARGET_NAME} Winmm Ws2_32) ENDIF(WIN32) -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () - find_package(Qt5 COMPONENTS Network Widgets) target_link_libraries(${TARGET_NAME} Qt5::Network) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index cb2065e256..ea4b54257b 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -206,9 +206,6 @@ else (APPLE) # we're using static GLEW, so define GLEW_STATIC add_definitions(-DGLEW_STATIC) - # add a definition for ssize_t so that windows doesn't bail - add_definitions(-Dssize_t=long) - target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" wsock32.lib opengl32.lib) endif() endif (APPLE) diff --git a/interface/src/voxels/OctreePacketProcessor.cpp b/interface/src/voxels/OctreePacketProcessor.cpp index 66190a5689..ee139ccf1d 100644 --- a/interface/src/voxels/OctreePacketProcessor.cpp +++ b/interface/src/voxels/OctreePacketProcessor.cpp @@ -26,7 +26,7 @@ void OctreePacketProcessor::processPacket(const SharedNodePointer& sendingNode, if (packetsToProcessCount() > WAY_BEHIND && Application::getInstance()->getLogger()->extraDebugging()) { qDebug("OctreePacketProcessor::processPacket() packets to process=%d", packetsToProcessCount()); } - ssize_t messageLength = mutablePacket.size(); + int messageLength = mutablePacket.size(); Application* app = Application::getInstance(); bool wasStatsPacket = false; diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 186067ba3f..26b98ca17f 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -10,8 +10,3 @@ find_package(Qt5 COMPONENTS Network Script) set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Network) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index 73d15f0b73..a066c3a73b 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -12,8 +12,3 @@ find_package(Qt5 COMPONENTS Network) set(DEPENDENCY_LIBRARIES Qt5::Network) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index 138b218381..9d7d452696 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -13,8 +13,3 @@ find_package(Qt5 COMPONENTS Network Script) set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index 3f6a969cbc..12047498c2 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -15,8 +15,3 @@ include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") set(DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}") set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index 29f7f85f9c..b0e8f14374 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -14,9 +14,4 @@ find_package(Qt5 COMPONENTS Network Script Widgets) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Widgets Qt5::Network) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index 20f6ef1ef8..45d0ab0b70 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -12,8 +12,3 @@ find_package(Qt5 COMPONENTS Network Script) set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/libraries/models/src/ModelEditPacketSender.cpp b/libraries/models/src/ModelEditPacketSender.cpp index 5059b8891b..c21a4a236a 100644 --- a/libraries/models/src/ModelEditPacketSender.cpp +++ b/libraries/models/src/ModelEditPacketSender.cpp @@ -38,7 +38,7 @@ void ModelEditPacketSender::sendEditModelMessage(PacketType type, ModelItemID mo } } -void ModelEditPacketSender::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { +void ModelEditPacketSender::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew) { ModelItem::adjustEditPacketForClockSkew(codeColorBuffer, length, clockSkew); } diff --git a/libraries/models/src/ModelEditPacketSender.h b/libraries/models/src/ModelEditPacketSender.h index 198c9a3be2..332f7f729d 100644 --- a/libraries/models/src/ModelEditPacketSender.h +++ b/libraries/models/src/ModelEditPacketSender.h @@ -32,6 +32,6 @@ public: // My server type is the model server virtual char getMyNodeType() const { return NodeType::ModelServer; } - virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew); + virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew); }; #endif // hifi_ModelEditPacketSender_h diff --git a/libraries/models/src/ModelItem.cpp b/libraries/models/src/ModelItem.cpp index d6cd8aebc5..e555aff7ed 100644 --- a/libraries/models/src/ModelItem.cpp +++ b/libraries/models/src/ModelItem.cpp @@ -634,7 +634,7 @@ bool ModelItem::encodeModelEditMessageDetails(PacketType command, ModelItemID id } // adjust any internal timestamps to fix clock skew for this server -void ModelItem::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { +void ModelItem::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew) { unsigned char* dataAt = codeColorBuffer; int octets = numberOfThreeBitSectionsInCode(dataAt); int lengthOfOctcode = bytesRequiredForCodeLength(octets); diff --git a/libraries/models/src/ModelItem.h b/libraries/models/src/ModelItem.h index 4a9a2af2c4..be52b1e235 100644 --- a/libraries/models/src/ModelItem.h +++ b/libraries/models/src/ModelItem.h @@ -270,7 +270,7 @@ public: static bool encodeModelEditMessageDetails(PacketType command, ModelItemID id, const ModelItemProperties& details, unsigned char* bufferOut, int sizeIn, int& sizeOut); - static void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew); + static void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew); void update(const quint64& now); diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index f41d410ce8..fe8cd003a3 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -10,8 +10,3 @@ find_package(Qt5 COMPONENTS Network) set(DEPENDENCY_LIBRARIES Qt5::Network) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/libraries/networking/src/PacketSender.h b/libraries/networking/src/PacketSender.h index 7d2c0dc8aa..29d9287127 100644 --- a/libraries/networking/src/PacketSender.h +++ b/libraries/networking/src/PacketSender.h @@ -39,10 +39,6 @@ public: ~PacketSender(); /// Add packet to outbound queue. - /// \param HifiSockAddr& address the destination address - /// \param packetData pointer to data - /// \param ssize_t packetLength size of data - /// \thread any thread, typically the application thread void queuePacketForSending(const SharedNodePointer& destinationNode, const QByteArray& packet); void setPacketsPerSecond(int packetsPerSecond); diff --git a/libraries/networking/src/ReceivedPacketProcessor.h b/libraries/networking/src/ReceivedPacketProcessor.h index 607f9e54c2..d5fc006882 100644 --- a/libraries/networking/src/ReceivedPacketProcessor.h +++ b/libraries/networking/src/ReceivedPacketProcessor.h @@ -24,10 +24,6 @@ public: ReceivedPacketProcessor() { } /// Add packet from network receive thread to the processing queue. - /// \param sockaddr& senderAddress the address of the sender - /// \param packetData pointer to received data - /// \param ssize_t packetLength size of received data - /// \thread network receive thread void queueReceivedPacket(const SharedNodePointer& sendingNode, const QByteArray& packet); /// Are there received packets waiting to be processed diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index efdb1bc70a..ca4e5caafd 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -16,8 +16,3 @@ include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") set(DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}") set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/libraries/octree/src/EditPacketBuffer.cpp b/libraries/octree/src/EditPacketBuffer.cpp index d6e7bf0183..6d2d8cc085 100644 --- a/libraries/octree/src/EditPacketBuffer.cpp +++ b/libraries/octree/src/EditPacketBuffer.cpp @@ -20,7 +20,7 @@ EditPacketBuffer::EditPacketBuffer() : } -EditPacketBuffer::EditPacketBuffer(PacketType type, unsigned char* buffer, ssize_t length, qint64 satoshiCost, QUuid nodeUUID) : +EditPacketBuffer::EditPacketBuffer(PacketType type, unsigned char* buffer, size_t length, qint64 satoshiCost, QUuid nodeUUID) : _nodeUUID(nodeUUID), _currentType(type), _currentSize(length), diff --git a/libraries/octree/src/EditPacketBuffer.h b/libraries/octree/src/EditPacketBuffer.h index 9b52cbc5e4..e816bf6558 100644 --- a/libraries/octree/src/EditPacketBuffer.h +++ b/libraries/octree/src/EditPacketBuffer.h @@ -21,13 +21,13 @@ class EditPacketBuffer { public: EditPacketBuffer(); - EditPacketBuffer(PacketType type, unsigned char* codeColorBuffer, ssize_t length, + EditPacketBuffer(PacketType type, unsigned char* codeColorBuffer, size_t length, qint64 satoshiCost = 0, const QUuid nodeUUID = QUuid()); QUuid _nodeUUID; PacketType _currentType; unsigned char _currentBuffer[MAX_PACKET_SIZE]; - ssize_t _currentSize; + size_t _currentSize; qint64 _satoshiCost; }; diff --git a/libraries/octree/src/JurisdictionListener.cpp b/libraries/octree/src/JurisdictionListener.cpp index 453ff10a42..f3d9e31acc 100644 --- a/libraries/octree/src/JurisdictionListener.cpp +++ b/libraries/octree/src/JurisdictionListener.cpp @@ -35,7 +35,7 @@ void JurisdictionListener::nodeKilled(SharedNodePointer node) { bool JurisdictionListener::queueJurisdictionRequest() { static unsigned char buffer[MAX_PACKET_SIZE]; unsigned char* bufferOut = &buffer[0]; - ssize_t sizeOut = populatePacketHeader(reinterpret_cast(bufferOut), PacketTypeJurisdictionRequest); + int sizeOut = populatePacketHeader(reinterpret_cast(bufferOut), PacketTypeJurisdictionRequest); int nodeCount = 0; NodeList* nodeList = NodeList::getInstance(); diff --git a/libraries/octree/src/JurisdictionListener.h b/libraries/octree/src/JurisdictionListener.h index 01f0392796..eb1c27f2ff 100644 --- a/libraries/octree/src/JurisdictionListener.h +++ b/libraries/octree/src/JurisdictionListener.h @@ -47,10 +47,6 @@ public slots: protected: /// Callback for processing of received packets. Will process any queued PacketType_JURISDICTION and update the /// jurisdiction map member variable - /// \param sockaddr& senderAddress the address of the sender - /// \param packetData pointer to received data - /// \param ssize_t packetLength size of received data - /// \thread "this" individual processing thread virtual void processPacket(const SharedNodePointer& sendingNode, const QByteArray& packet); private: diff --git a/libraries/octree/src/JurisdictionSender.cpp b/libraries/octree/src/JurisdictionSender.cpp index c151999305..d78d883204 100644 --- a/libraries/octree/src/JurisdictionSender.cpp +++ b/libraries/octree/src/JurisdictionSender.cpp @@ -47,7 +47,7 @@ bool JurisdictionSender::process() { // add our packet to our own queue, then let the PacketSender class do the rest of the work. static unsigned char buffer[MAX_PACKET_SIZE]; unsigned char* bufferOut = &buffer[0]; - ssize_t sizeOut = 0; + int sizeOut = 0; if (_jurisdictionMap) { sizeOut = _jurisdictionMap->packIntoMessage(bufferOut, MAX_PACKET_SIZE); diff --git a/libraries/octree/src/OctreeEditPacketSender.cpp b/libraries/octree/src/OctreeEditPacketSender.cpp index 543f47273c..d4bdcaa59e 100644 --- a/libraries/octree/src/OctreeEditPacketSender.cpp +++ b/libraries/octree/src/OctreeEditPacketSender.cpp @@ -83,7 +83,7 @@ bool OctreeEditPacketSender::serversExist() const { // This method is called when the edit packet layer has determined that it has a fully formed packet destined for // a known nodeID. void OctreeEditPacketSender::queuePacketToNode(const QUuid& nodeUUID, unsigned char* buffer, - ssize_t length, qint64 satoshiCost) { + size_t length, qint64 satoshiCost) { NodeList* nodeList = NodeList::getInstance(); foreach (const SharedNodePointer& node, nodeList->getNodeHash()) { @@ -161,7 +161,7 @@ void OctreeEditPacketSender::processPreServerExistsPackets() { } void OctreeEditPacketSender::queuePendingPacketToNodes(PacketType type, unsigned char* buffer, - ssize_t length, qint64 satoshiCost) { + size_t length, qint64 satoshiCost) { // If we're asked to save messages while waiting for voxel servers to arrive, then do so... if (_maxPendingMessages > 0) { @@ -179,7 +179,7 @@ void OctreeEditPacketSender::queuePendingPacketToNodes(PacketType type, unsigned } } -void OctreeEditPacketSender::queuePacketToNodes(unsigned char* buffer, ssize_t length, qint64 satoshiCost) { +void OctreeEditPacketSender::queuePacketToNodes(unsigned char* buffer, size_t length, qint64 satoshiCost) { if (!_shouldSend) { return; // bail early } @@ -215,7 +215,7 @@ void OctreeEditPacketSender::queuePacketToNodes(unsigned char* buffer, ssize_t l // NOTE: codeColorBuffer - is JUST the octcode/color and does not contain the packet header! void OctreeEditPacketSender::queueOctreeEditMessage(PacketType type, unsigned char* codeColorBuffer, - ssize_t length, qint64 satoshiCost) { + size_t length, qint64 satoshiCost) { if (!_shouldSend) { return; // bail early diff --git a/libraries/octree/src/OctreeEditPacketSender.h b/libraries/octree/src/OctreeEditPacketSender.h index a11c626003..cefa5cefb0 100644 --- a/libraries/octree/src/OctreeEditPacketSender.h +++ b/libraries/octree/src/OctreeEditPacketSender.h @@ -30,7 +30,7 @@ public: /// Queues a single edit message. Will potentially send a pending multi-command packet. Determines which server /// node or nodes the packet should be sent to. Can be called even before servers are known, in which case up to /// MaxPendingMessages will be buffered and processed when servers are known. - void queueOctreeEditMessage(PacketType type, unsigned char* buffer, ssize_t length, qint64 satoshiCost = 0); + void queueOctreeEditMessage(PacketType type, unsigned char* buffer, size_t length, qint64 satoshiCost = 0); /// Releases all queued messages even if those messages haven't filled an MTU packet. This will move the packed message /// packets onto the send queue. If running in threaded mode, the caller does not need to do any further processing to @@ -81,7 +81,7 @@ public: // you must override these... virtual char getMyNodeType() const = 0; - virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { }; + virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew) { }; bool hasDestinationWalletUUID() const { return !_destinationWalletUUID.isNull(); } void setDestinationWalletUUID(const QUuid& destinationWalletUUID) { _destinationWalletUUID = destinationWalletUUID; } @@ -97,9 +97,9 @@ signals: protected: bool _shouldSend; - void queuePacketToNode(const QUuid& nodeID, unsigned char* buffer, ssize_t length, qint64 satoshiCost = 0); - void queuePendingPacketToNodes(PacketType type, unsigned char* buffer, ssize_t length, qint64 satoshiCost = 0); - void queuePacketToNodes(unsigned char* buffer, ssize_t length, qint64 satoshiCost = 0); + void queuePacketToNode(const QUuid& nodeID, unsigned char* buffer, size_t length, qint64 satoshiCost = 0); + void queuePendingPacketToNodes(PacketType type, unsigned char* buffer, size_t length, qint64 satoshiCost = 0); + void queuePacketToNodes(unsigned char* buffer, size_t length, qint64 satoshiCost = 0); void initializePacket(EditPacketBuffer& packetBuffer, PacketType type); void releaseQueuedPacket(EditPacketBuffer& packetBuffer); // releases specific queued packet diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index 0ab11e3f82..8efeedc9d9 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -12,9 +12,4 @@ find_package(Qt5 COMPONENTS Gui Network Script) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script Qt5::Gui) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file diff --git a/libraries/particles/src/Particle.cpp b/libraries/particles/src/Particle.cpp index 5db285ebeb..e3b568365b 100644 --- a/libraries/particles/src/Particle.cpp +++ b/libraries/particles/src/Particle.cpp @@ -856,7 +856,7 @@ bool Particle::encodeParticleEditMessageDetails(PacketType command, ParticleID i } // adjust any internal timestamps to fix clock skew for this server -void Particle::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { +void Particle::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew) { unsigned char* dataAt = codeColorBuffer; int octets = numberOfThreeBitSectionsInCode(dataAt); int lengthOfOctcode = bytesRequiredForCodeLength(octets); diff --git a/libraries/particles/src/Particle.h b/libraries/particles/src/Particle.h index c243363241..1ee0f6e79b 100644 --- a/libraries/particles/src/Particle.h +++ b/libraries/particles/src/Particle.h @@ -292,7 +292,7 @@ public: static bool encodeParticleEditMessageDetails(PacketType command, ParticleID id, const ParticleProperties& details, unsigned char* bufferOut, int sizeIn, int& sizeOut); - static void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew); + static void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew); void applyHardCollision(const CollisionInfo& collisionInfo); diff --git a/libraries/particles/src/ParticleEditPacketSender.cpp b/libraries/particles/src/ParticleEditPacketSender.cpp index 21a910ff16..689b734521 100644 --- a/libraries/particles/src/ParticleEditPacketSender.cpp +++ b/libraries/particles/src/ParticleEditPacketSender.cpp @@ -38,7 +38,7 @@ void ParticleEditPacketSender::sendEditParticleMessage(PacketType type, Particle } } -void ParticleEditPacketSender::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew) { +void ParticleEditPacketSender::adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew) { Particle::adjustEditPacketForClockSkew(codeColorBuffer, length, clockSkew); } diff --git a/libraries/particles/src/ParticleEditPacketSender.h b/libraries/particles/src/ParticleEditPacketSender.h index 5a367347ea..2ee6d84eb8 100644 --- a/libraries/particles/src/ParticleEditPacketSender.h +++ b/libraries/particles/src/ParticleEditPacketSender.h @@ -31,6 +31,6 @@ public: // My server type is the particle server virtual char getMyNodeType() const { return NodeType::ParticleServer; } - virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, ssize_t length, int clockSkew); + virtual void adjustEditPacketForClockSkew(unsigned char* codeColorBuffer, size_t length, int clockSkew); }; #endif // hifi_ParticleEditPacketSender_h diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index f9b4b7d60f..0b79530210 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -11,9 +11,4 @@ find_package(Qt5 COMPONENTS Gui Network Script Widgets) # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file diff --git a/libraries/voxels/CMakeLists.txt b/libraries/voxels/CMakeLists.txt index c421f6514f..739fe3ef62 100644 --- a/libraries/voxels/CMakeLists.txt +++ b/libraries/voxels/CMakeLists.txt @@ -12,8 +12,3 @@ find_package(Qt5 COMPONENTS Widgets Script) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets Qt5::Script) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file diff --git a/libraries/voxels/src/VoxelEditPacketSender.h b/libraries/voxels/src/VoxelEditPacketSender.h index 560c585ed5..3b85155036 100644 --- a/libraries/voxels/src/VoxelEditPacketSender.h +++ b/libraries/voxels/src/VoxelEditPacketSender.h @@ -28,7 +28,7 @@ public: /// Queues a single voxel edit message. Will potentially send a pending multi-command packet. Determines which voxel-server /// node or nodes the packet should be sent to. Can be called even before voxel servers are known, in which case up to /// MaxPendingMessages will be buffered and processed when voxel servers are known. - void queueVoxelEditMessage(PacketType type, unsigned char* codeColorBuffer, ssize_t length) { + void queueVoxelEditMessage(PacketType type, unsigned char* codeColorBuffer, size_t length) { queueOctreeEditMessage(type, codeColorBuffer, length); } diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index a4888b2c66..85442db783 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -6,11 +6,5 @@ setup_hifi_project(${TARGET_NAME} TRUE) link_hifi_libraries(${TARGET_NAME} octree) IF (WIN32) - # add a definition for ssize_t so that windows doesn't bail - add_definitions(-Dssize_t=long) - - #target_link_libraries(${TARGET_NAME} Winmm Ws2_32) - target_link_libraries(${TARGET_NAME} wsock32.lib) + target_link_libraries(${TARGET_NAME} wsock32.lib) ENDIF(WIN32) - - diff --git a/voxel-edit/CMakeLists.txt b/voxel-edit/CMakeLists.txt index 8c315c92a0..db22f040b7 100644 --- a/voxel-edit/CMakeLists.txt +++ b/voxel-edit/CMakeLists.txt @@ -1,8 +1,3 @@ set(TARGET_NAME voxel-edit) -setup_hifi_project(${TARGET_NAME} TRUE) - -# add a definition for ssize_t so that windows doesn't bail -if (WIN32) - add_definitions(-Dssize_t=long) -endif () \ No newline at end of file +setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file From 1f0a722d0db68c11419102223911697959cdf077 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 10:17:29 -0700 Subject: [PATCH 18/43] remove antequated windows libraries that have been replaced by Qt usage --- assignment-client/CMakeLists.txt | 4 ---- domain-server/CMakeLists.txt | 4 ---- tests/audio/CMakeLists.txt | 5 ----- tests/jitter/CMakeLists.txt | 7 +------ tests/metavoxels/CMakeLists.txt | 4 ---- tests/networking/CMakeLists.txt | 4 ---- 6 files changed, 1 insertion(+), 27 deletions(-) diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index d4281eb185..ab448bc5bd 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -14,9 +14,5 @@ if (UNIX) target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} ${CMAKE_DL_LIBS}) endif (UNIX) -IF (WIN32) - target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} Winmm Ws2_32) -ENDIF(WIN32) - find_package(Qt5 COMPONENTS Gui Network Script Widgets) target_link_libraries(${TARGET_NAME} Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index c04ba33a5d..7f9dc2db37 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -14,9 +14,5 @@ add_custom_command(TARGET ${TARGET_NAME} POST_BUILD # link the shared hifi library link_hifi_libraries(${TARGET_NAME} embedded-webserver networking shared) -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - find_package(Qt5 COMPONENTS Network Widgets) target_link_libraries(${TARGET_NAME} Qt5::Network) diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index 15da1afaa1..51b42780c8 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -7,8 +7,3 @@ include_glm(${TARGET_NAME} ${ROOT_DIR}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared audio networking) - -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - diff --git a/tests/jitter/CMakeLists.txt b/tests/jitter/CMakeLists.txt index 3b1d544690..4fb3d56492 100644 --- a/tests/jitter/CMakeLists.txt +++ b/tests/jitter/CMakeLists.txt @@ -3,9 +3,4 @@ set(TARGET_NAME jitter-tests) setup_hifi_project(${TARGET_NAME} TRUE) # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared networking) - -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - +link_hifi_libraries(${TARGET_NAME} shared networking) \ No newline at end of file diff --git a/tests/metavoxels/CMakeLists.txt b/tests/metavoxels/CMakeLists.txt index 233988f849..d459ea1fed 100644 --- a/tests/metavoxels/CMakeLists.txt +++ b/tests/metavoxels/CMakeLists.txt @@ -9,9 +9,5 @@ setup_hifi_project(${TARGET_NAME} TRUE "${AUTOMTC_SRC}") # link in the shared libraries link_hifi_libraries(${TARGET_NAME} metavoxels networking shared) -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script) diff --git a/tests/networking/CMakeLists.txt b/tests/networking/CMakeLists.txt index 819229d28f..ec48bb80cd 100644 --- a/tests/networking/CMakeLists.txt +++ b/tests/networking/CMakeLists.txt @@ -5,7 +5,3 @@ setup_hifi_project(${TARGET_NAME} TRUE) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared networking) -IF (WIN32) - target_link_libraries(${TARGET_NAME} Winmm Ws2_32) -ENDIF(WIN32) - From c9f8433a2dba2c78951cb5a35ef0fe17ceb0f3a1 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 10:44:58 -0700 Subject: [PATCH 19/43] tweak setup_hifi_library to bubble up full path of Qt modules --- cmake/macros/SetupHifiLibrary.cmake | 28 +++++++++++++++------ libraries/animation/CMakeLists.txt | 12 +++------ libraries/audio/CMakeLists.txt | 12 +++------ libraries/avatars/CMakeLists.txt | 12 +++------ libraries/embedded-webserver/CMakeLists.txt | 17 ++----------- libraries/fbx/CMakeLists.txt | 1 + libraries/metavoxels/CMakeLists.txt | 12 +++------ libraries/models/CMakeLists.txt | 12 +++------ libraries/networking/CMakeLists.txt | 12 +++------ libraries/octree/CMakeLists.txt | 3 ++- libraries/particles/CMakeLists.txt | 12 +++------ libraries/script-engine/CMakeLists.txt | 12 +++------ libraries/shared/CMakeLists.txt | 9 ++----- libraries/voxels/CMakeLists.txt | 10 +++++--- tests/audio/CMakeLists.txt | 2 +- tools/CMakeLists.txt | 1 - tools/mtc/CMakeLists.txt | 5 ---- 17 files changed, 59 insertions(+), 113 deletions(-) diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index ff4ae3b4f3..6da3755ea4 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -13,14 +13,28 @@ macro(SETUP_HIFI_LIBRARY TARGET) # grab the implemenation and header files file(GLOB LIB_SRCS src/*.h src/*.cpp) - set(LIB_SRCS ${LIB_SRCS} ${WRAPPED_SRCS}) + set(LIB_SRCS ${LIB_SRCS}) - # create a library and set the property so it can be referenced later - add_library(${TARGET} ${LIB_SRCS} ${ARGN}) + # create a library and set the property so it can be referenced later + add_library(${TARGET} ${LIB_SRCS} ${AUTOMTC_SRC}) - find_package(Qt5Core REQUIRED) - qt5_use_modules(${TARGET} Core) - - target_link_libraries(${TARGET} ${QT_LIBRARIES}) + set(QT_MODULES_TO_LINK ${ARGN}) + list(APPEND QT_MODULES_TO_LINK Core) + + find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK}) + + foreach(QT_MODULE ${QT_MODULES_TO_LINK}) + # link this Qt module to ourselves + target_link_libraries(${TARGET} Qt5::${QT_MODULE}) + + get_target_property(QT_LIBRARY_LOCATION Qt5::${QT_MODULE} LOCATION) + + # add the actual path to the Qt module to a QT_LIBRARIES variable + list(APPEND QT_LIBRARIES ${QT_LIBRARY_LOCATION}) + endforeach() + + if (QT_LIBRARIES) + set_target_properties(${TARGET} PROPERTIES DEPENDENCY_LIBRARIES "${QT_LIBRARIES}") + endif () endmacro(SETUP_HIFI_LIBRARY _target) \ No newline at end of file diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 26b98ca17f..9c419d9369 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -1,12 +1,6 @@ set(TARGET_NAME animation) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network Script) -link_hifi_libraries(${TARGET_NAME} shared fbx) - -find_package(Qt5 COMPONENTS Network Script) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +link_hifi_libraries(${TARGET_NAME} shared fbx) \ No newline at end of file diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index a066c3a73b..354a3772dd 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -1,14 +1,8 @@ set(TARGET_NAME audio) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network) include_glm(${TARGET_NAME} "${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} networking shared) - -find_package(Qt5 COMPONENTS Network) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +link_hifi_libraries(${TARGET_NAME} networking shared) \ No newline at end of file diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index 9d7d452696..d05faf3b27 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -1,15 +1,9 @@ set(TARGET_NAME avatars) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree voxels networking) -include_hifi_library_headers(fbx) - -find_package(Qt5 COMPONENTS Network Script) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +include_hifi_library_headers(fbx) \ No newline at end of file diff --git a/libraries/embedded-webserver/CMakeLists.txt b/libraries/embedded-webserver/CMakeLists.txt index 5b815625ba..c299aa654d 100644 --- a/libraries/embedded-webserver/CMakeLists.txt +++ b/libraries/embedded-webserver/CMakeLists.txt @@ -1,17 +1,4 @@ -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -# setup for find modules -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/modules/") - set(TARGET_NAME embedded-webserver) -include(${MACRO_DIR}/SetupHifiLibrary.cmake) -setup_hifi_library(${TARGET_NAME}) - -find_package(Qt5 COMPONENTS Network) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network) \ No newline at end of file diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index 12047498c2..e9658de4a2 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -1,5 +1,6 @@ set(TARGET_NAME fbx) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(${TARGET_NAME}) include_glm(${TARGET_NAME} "${ROOT_DIR}") diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index b0e8f14374..20b448725f 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -2,16 +2,10 @@ set(TARGET_NAME metavoxels) auto_mtc(${TARGET_NAME} "${ROOT_DIR}") -setup_hifi_library(${TARGET_NAME} "${AUTOMTC_SRC}") +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network Scripts Widgets) # link in the networking library link_hifi_libraries(${TARGET_NAME} shared networking) -include_glm(${TARGET_NAME} "${ROOT_DIR}") - -find_package(Qt5 COMPONENTS Network Script Widgets) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Script Qt5::Widgets Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file +include_glm(${TARGET_NAME} "${ROOT_DIR}") \ No newline at end of file diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index 45d0ab0b70..c0610b0501 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -1,14 +1,8 @@ set(TARGET_NAME models) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) - -find_package(Qt5 COMPONENTS Network Script) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) \ No newline at end of file diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index fe8cd003a3..fb9f07b81a 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -1,12 +1,6 @@ set(TARGET_NAME networking) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network) -link_hifi_libraries(${TARGET_NAME} shared) - -find_package(Qt5 COMPONENTS Network) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +link_hifi_libraries(${TARGET_NAME} shared) \ No newline at end of file diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index ca4e5caafd..340b2393e6 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -1,5 +1,6 @@ set(TARGET_NAME octree) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(${TARGET_NAME}) include_glm(${TARGET_NAME} "${ROOT_DIR}") @@ -15,4 +16,4 @@ include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") # set a property indicating the libraries we are dependent on and link them to ourselves set(DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}") set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index 8efeedc9d9..2f523b22f7 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -1,15 +1,9 @@ set(TARGET_NAME particles) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Gui Network Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) -include_hifi_library_headers(script-engine) - -find_package(Qt5 COMPONENTS Gui Network Script) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Network Qt5::Script Qt5::Gui) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file +include_hifi_library_headers(script-engine) \ No newline at end of file diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index 0b79530210..cce7d8d07b 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -1,14 +1,8 @@ set(TARGET_NAME script-engine) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Gui Network Script Widgets) include_glm(${TARGET_NAME} "${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx particles models animation) - -find_package(Qt5 COMPONENTS Gui Network Script Widgets) - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx particles models animation) \ No newline at end of file diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index b8e34739b8..9cc1b968dc 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -1,9 +1,4 @@ set(TARGET_NAME shared) -setup_hifi_library(${TARGET_NAME}) -find_package(Qt5 COMPONENTS Network Widgets) - -# bubble up the libraries we are dependent on and link them to ourselves -list(APPEND DEPENDENCY_LIBRARIES Qt5::Network Qt5::Widgets) -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${DEPENDENCY_LIBRARIES}") -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Network Widgets) \ No newline at end of file diff --git a/libraries/voxels/CMakeLists.txt b/libraries/voxels/CMakeLists.txt index 739fe3ef62..7f200523de 100644 --- a/libraries/voxels/CMakeLists.txt +++ b/libraries/voxels/CMakeLists.txt @@ -1,6 +1,7 @@ set(TARGET_NAME voxels) -setup_hifi_library(${TARGET_NAME}) +# use setup_hifi_library macro to setup our project and link appropriate Qt modules +setup_hifi_library(${TARGET_NAME} Widgets Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") @@ -8,7 +9,8 @@ link_hifi_libraries(${TARGET_NAME} shared octree networking) # link ZLIB find_package(ZLIB) -find_package(Qt5 COMPONENTS Widgets Script) - include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -target_link_libraries(${TARGET_NAME} "${ZLIB_LIBRARIES}" Qt5::Widgets Qt5::Script) + +get_target_property(LINKED_LIBRARIES ${TARGET_NAME} DEPENDENCY_LIBRARIES) +list(APPEND DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}") +list(REMOVE_DUPLICATES DEPENDENCY_LIBRARIES) \ No newline at end of file diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index 51b42780c8..34d053b008 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -6,4 +6,4 @@ setup_hifi_project(${TARGET_NAME} TRUE) include_glm(${TARGET_NAME} ${ROOT_DIR}) # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared audio networking) +link_hifi_libraries(${TARGET_NAME} shared audio networking) \ No newline at end of file diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index c9c0690cc7..32a82627a3 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,4 +1,3 @@ - # add the tool directories add_subdirectory(bitstream2json) add_subdirectory(json2bitstream) diff --git a/tools/mtc/CMakeLists.txt b/tools/mtc/CMakeLists.txt index 582c5e3bfd..467d03d241 100644 --- a/tools/mtc/CMakeLists.txt +++ b/tools/mtc/CMakeLists.txt @@ -1,7 +1,2 @@ set(TARGET_NAME mtc) - -set(ROOT_DIR ../..) -set(MACRO_DIR "${ROOT_DIR}/cmake/macros") - -include(${MACRO_DIR}/SetupHifiProject.cmake) setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file From fc92b93326755028d74bf0ba951da6ae6d85c3ac Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 10:46:05 -0700 Subject: [PATCH 20/43] fix typo in metavoxels library setup --- libraries/metavoxels/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index 20b448725f..a8d6de698b 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -3,7 +3,7 @@ set(TARGET_NAME metavoxels) auto_mtc(${TARGET_NAME} "${ROOT_DIR}") # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network Scripts Widgets) +setup_hifi_library(${TARGET_NAME} Network Script Widgets) # link in the networking library link_hifi_libraries(${TARGET_NAME} shared networking) From 26f7b1ba62bf37cb1c0e0f780bac16be7f651d3e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 11:45:10 -0700 Subject: [PATCH 21/43] add macro to link shared dependencies to target --- assignment-client/CMakeLists.txt | 7 +++--- cmake/macros/LinkHifiLibraries.cmake | 11 ++++---- .../LinkSharedDependenciesToTarget.cmake | 25 +++++++++++++++++++ cmake/macros/SetupHifiLibrary.cmake | 15 +++-------- cmake/macros/SetupHifiProject.cmake | 21 +++++++++++----- domain-server/CMakeLists.txt | 2 +- libraries/animation/CMakeLists.txt | 5 +++- libraries/audio/CMakeLists.txt | 5 +++- libraries/avatars/CMakeLists.txt | 5 +++- libraries/embedded-webserver/CMakeLists.txt | 5 +++- libraries/fbx/CMakeLists.txt | 9 +++---- libraries/metavoxels/CMakeLists.txt | 5 +++- libraries/models/CMakeLists.txt | 5 +++- libraries/networking/CMakeLists.txt | 5 +++- libraries/octree/CMakeLists.txt | 14 ++++++----- libraries/particles/CMakeLists.txt | 5 +++- libraries/script-engine/CMakeLists.txt | 5 +++- libraries/shared/CMakeLists.txt | 5 +++- libraries/voxels/CMakeLists.txt | 10 +++++--- tests/audio/CMakeLists.txt | 2 +- tests/jitter/CMakeLists.txt | 2 +- tests/metavoxels/CMakeLists.txt | 2 +- tests/networking/CMakeLists.txt | 2 +- tests/octree/CMakeLists.txt | 2 +- tests/physics/CMakeLists.txt | 2 +- tests/shared/CMakeLists.txt | 2 +- tools/bitstream2json/CMakeLists.txt | 2 +- tools/json2bitstream/CMakeLists.txt | 2 +- tools/mtc/CMakeLists.txt | 2 +- voxel-edit/CMakeLists.txt | 2 +- 30 files changed, 121 insertions(+), 65 deletions(-) create mode 100644 cmake/macros/LinkSharedDependenciesToTarget.cmake diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index ab448bc5bd..9f8542c42e 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME assignment-client) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME} Core Gui Network Script Widgets) include_glm(${TARGET_NAME}) @@ -11,8 +11,7 @@ link_hifi_libraries(${TARGET_NAME} ) if (UNIX) - target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES} ${CMAKE_DL_LIBS}) + list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK ${CMAKE_DL_LIBS}) endif (UNIX) -find_package(Qt5 COMPONENTS Gui Network Script Widgets) -target_link_libraries(${TARGET_NAME} Qt5::Gui Qt5::Network Qt5::Script Qt5::Widgets) +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/cmake/macros/LinkHifiLibraries.cmake b/cmake/macros/LinkHifiLibraries.cmake index 4c6e2c3215..96c5d82cae 100644 --- a/cmake/macros/LinkHifiLibraries.cmake +++ b/cmake/macros/LinkHifiLibraries.cmake @@ -22,13 +22,12 @@ macro(LINK_HIFI_LIBRARIES TARGET) add_dependencies(${TARGET} ${HIFI_LIBRARY}) + # link the actual library + list(APPEND ${TARGET}_LIBRARIES_TO_LINK ${HIFI_LIBRARY}) + + # ask the library what its dynamic dependencies are and link them get_target_property(LINKED_TARGET_DEPENDENCY_LIBRARIES ${HIFI_LIBRARY} DEPENDENCY_LIBRARIES) - - if (LINKED_TARGET_DEPENDENCY_LIBRARIES) - target_link_libraries(${TARGET} ${HIFI_LIBRARY} ${LINKED_TARGET_DEPENDENCY_LIBRARIES}) - else () - target_link_libraries(${TARGET} ${HIFI_LIBRARY}) - endif () + list(APPEND ${TARGET}_LIBRARIES_TO_LINK ${LINKED_TARGET_DEPENDENCY_LIBRARIES}) endforeach() diff --git a/cmake/macros/LinkSharedDependenciesToTarget.cmake b/cmake/macros/LinkSharedDependenciesToTarget.cmake new file mode 100644 index 0000000000..42f7109807 --- /dev/null +++ b/cmake/macros/LinkSharedDependenciesToTarget.cmake @@ -0,0 +1,25 @@ +# +# LinkHifiLibrary.cmake +# cmake/macros +# +# Copyright 2014 High Fidelity, Inc. +# Created by Stephen Birarda on August 8, 2014 +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + +macro(LINK_SHARED_DEPENDENCIES_TO_TARGET TARGET) + if (${TARGET}_LIBRARIES_TO_LINK) + list(REMOVE_DUPLICATES ${TARGET}_LIBRARIES_TO_LINK) + + # link these libraries to our target + target_link_libraries(${TARGET} ${${TARGET}_LIBRARIES_TO_LINK}) + endif () + + # we've already linked our Qt modules, but we need to bubble them up to parents + list(APPEND ${TARGET}_LIBRARIES_TO_LINK "${${TARGET}_QT_MODULES_TO_LINK}") + + # set the property on this target so it can be retreived by targets linking to us + set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${${TARGET}_LIBRARIES_TO_LINK}") +endmacro(LINK_SHARED_DEPENDENCIES_TO_TARGET _target) \ No newline at end of file diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index 6da3755ea4..73ee208b98 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -15,7 +15,7 @@ macro(SETUP_HIFI_LIBRARY TARGET) file(GLOB LIB_SRCS src/*.h src/*.cpp) set(LIB_SRCS ${LIB_SRCS}) - # create a library and set the property so it can be referenced later + # create a library and set the property so it can be referenced later add_library(${TARGET} ${LIB_SRCS} ${AUTOMTC_SRC}) set(QT_MODULES_TO_LINK ${ARGN}) @@ -24,17 +24,10 @@ macro(SETUP_HIFI_LIBRARY TARGET) find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK}) foreach(QT_MODULE ${QT_MODULES_TO_LINK}) - # link this Qt module to ourselves - target_link_libraries(${TARGET} Qt5::${QT_MODULE}) - get_target_property(QT_LIBRARY_LOCATION Qt5::${QT_MODULE} LOCATION) - # add the actual path to the Qt module to a QT_LIBRARIES variable - list(APPEND QT_LIBRARIES ${QT_LIBRARY_LOCATION}) + # add the actual path to the Qt module to our LIBRARIES_TO_LINK variable + target_link_libraries(${TARGET} Qt5::${QT_MODULE}) + list(APPEND ${TARGET}_QT_MODULES_TO_LINK ${QT_LIBRARY_LOCATION}) endforeach() - - if (QT_LIBRARIES) - set_target_properties(${TARGET} PROPERTIES DEPENDENCY_LIBRARIES "${QT_LIBRARIES}") - endif () - endmacro(SETUP_HIFI_LIBRARY _target) \ No newline at end of file diff --git a/cmake/macros/SetupHifiProject.cmake b/cmake/macros/SetupHifiProject.cmake index 281aa42650..c680790f02 100644 --- a/cmake/macros/SetupHifiProject.cmake +++ b/cmake/macros/SetupHifiProject.cmake @@ -7,7 +7,7 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(SETUP_HIFI_PROJECT TARGET INCLUDE_QT) +macro(SETUP_HIFI_PROJECT TARGET) project(${TARGET}) # grab the implemenation and header files @@ -23,10 +23,19 @@ macro(SETUP_HIFI_PROJECT TARGET INCLUDE_QT) endforeach() # add the executable, include additional optional sources - add_executable(${TARGET} ${TARGET_SRCS} ${ARGN}) + add_executable(${TARGET} ${TARGET_SRCS} "${AUTOMTC_SRC}") + + set(QT_MODULES_TO_LINK ${ARGN}) + list(APPEND QT_MODULES_TO_LINK Core) + + find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK}) + + foreach(QT_MODULE ${QT_MODULES_TO_LINK}) + target_link_libraries(${TARGET} Qt5::${QT_MODULE}) + + # add the actual path to the Qt module to our LIBRARIES_TO_LINK variable + get_target_property(QT_LIBRARY_LOCATION Qt5::${QT_MODULE} LOCATION) + list(APPEND ${TARGET}_QT_MODULES_TO_LINK ${QT_LIBRARY_LOCATION}) + endforeach() - if (${INCLUDE_QT}) - find_package(Qt5 COMPONENTS Core) - target_link_libraries(${TARGET} Qt5::Core) - endif () endmacro() \ No newline at end of file diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 7f9dc2db37..3c1d34ba01 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME domain-server) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME}) # remove and then copy the files for the webserver add_custom_command(TARGET ${TARGET_NAME} POST_BUILD diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 9c419d9369..19fa087092 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -3,4 +3,7 @@ set(TARGET_NAME animation) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(${TARGET_NAME} Network Script) -link_hifi_libraries(${TARGET_NAME} shared fbx) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} shared fbx) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index 354a3772dd..8487f48ad3 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -5,4 +5,7 @@ setup_hifi_library(${TARGET_NAME} Network) include_glm(${TARGET_NAME} "${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} networking shared) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} networking shared) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index d05faf3b27..2791589abb 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -6,4 +6,7 @@ setup_hifi_library(${TARGET_NAME} Network Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree voxels networking) -include_hifi_library_headers(fbx) \ No newline at end of file +include_hifi_library_headers(fbx) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/embedded-webserver/CMakeLists.txt b/libraries/embedded-webserver/CMakeLists.txt index c299aa654d..b397003133 100644 --- a/libraries/embedded-webserver/CMakeLists.txt +++ b/libraries/embedded-webserver/CMakeLists.txt @@ -1,4 +1,7 @@ set(TARGET_NAME embedded-webserver) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network) \ No newline at end of file +setup_hifi_library(${TARGET_NAME} Network) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index e9658de4a2..d02cc918fc 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -7,12 +7,9 @@ include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared networking octree voxels) -# link ZLIB find_package(ZLIB) - include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") +list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}") -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index a8d6de698b..b9a03bf0f4 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -8,4 +8,7 @@ setup_hifi_library(${TARGET_NAME} Network Script Widgets) # link in the networking library link_hifi_libraries(${TARGET_NAME} shared networking) -include_glm(${TARGET_NAME} "${ROOT_DIR}") \ No newline at end of file +include_glm(${TARGET_NAME} "${ROOT_DIR}") + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index c0610b0501..89178f193a 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -5,4 +5,7 @@ setup_hifi_library(${TARGET_NAME} Network Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index fb9f07b81a..c2b86e2218 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -3,4 +3,7 @@ set(TARGET_NAME networking) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library(${TARGET_NAME} Network) -link_hifi_libraries(${TARGET_NAME} shared) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} shared) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index 340b2393e6..1fa730aad7 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -7,13 +7,15 @@ include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared networking) -# link ZLIB +# find ZLIB and OpenSSL find_package(ZLIB) find_package(OpenSSL REQUIRED) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") - -# set a property indicating the libraries we are dependent on and link them to ourselves -set(DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}") -set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES ${DEPENDENCY_LIBRARIES}) -target_link_libraries(${TARGET_NAME} ${DEPENDENCY_LIBRARIES}) \ No newline at end of file + +# append ZLIB and OpenSSL to our list of libraries to link +list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") +list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${OPENSSL_LIBRARIES}") + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index 2f523b22f7..f306c0a749 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -6,4 +6,7 @@ setup_hifi_library(${TARGET_NAME} Gui Network Script) include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) -include_hifi_library_headers(script-engine) \ No newline at end of file +include_hifi_library_headers(script-engine) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index cce7d8d07b..a16d6270c9 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -5,4 +5,7 @@ setup_hifi_library(${TARGET_NAME} Gui Network Script Widgets) include_glm(${TARGET_NAME} "${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx particles models animation) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx particles models animation) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 9cc1b968dc..1a6b39ea59 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -1,4 +1,7 @@ set(TARGET_NAME shared) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network Widgets) \ No newline at end of file +setup_hifi_library(${TARGET_NAME} Network Widgets) + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/libraries/voxels/CMakeLists.txt b/libraries/voxels/CMakeLists.txt index 7f200523de..87841ca29f 100644 --- a/libraries/voxels/CMakeLists.txt +++ b/libraries/voxels/CMakeLists.txt @@ -7,10 +7,12 @@ include_glm(${TARGET_NAME} "${ROOT_DIR}") link_hifi_libraries(${TARGET_NAME} shared octree networking) -# link ZLIB +# find ZLIB find_package(ZLIB) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") -get_target_property(LINKED_LIBRARIES ${TARGET_NAME} DEPENDENCY_LIBRARIES) -list(APPEND DEPENDENCY_LIBRARIES "${ZLIB_LIBRARIES}") -list(REMOVE_DUPLICATES DEPENDENCY_LIBRARIES) \ No newline at end of file +# add it to our list of libraries to link +list(APPEND ${TARGET}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") + +# call macro to link our dependencies and bubble them up via a property on our target +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index 34d053b008..f5d9388508 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME audio-tests) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME}) #include glm include_glm(${TARGET_NAME} ${ROOT_DIR}) diff --git a/tests/jitter/CMakeLists.txt b/tests/jitter/CMakeLists.txt index 4fb3d56492..9c861eac3e 100644 --- a/tests/jitter/CMakeLists.txt +++ b/tests/jitter/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME jitter-tests) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared networking) \ No newline at end of file diff --git a/tests/metavoxels/CMakeLists.txt b/tests/metavoxels/CMakeLists.txt index d459ea1fed..358a959eb0 100644 --- a/tests/metavoxels/CMakeLists.txt +++ b/tests/metavoxels/CMakeLists.txt @@ -4,7 +4,7 @@ find_package(Qt5 COMPONENTS Network Script Widgets) auto_mtc(${TARGET_NAME} "${ROOT_DIR}") -setup_hifi_project(${TARGET_NAME} TRUE "${AUTOMTC_SRC}") +setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} metavoxels networking shared) diff --git a/tests/networking/CMakeLists.txt b/tests/networking/CMakeLists.txt index ec48bb80cd..68de37a1d2 100644 --- a/tests/networking/CMakeLists.txt +++ b/tests/networking/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME networking-tests) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared networking) diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index 85442db783..a8e27e0084 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME octree-tests) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} octree) diff --git a/tests/physics/CMakeLists.txt b/tests/physics/CMakeLists.txt index 2161723619..01bdf5a96b 100644 --- a/tests/physics/CMakeLists.txt +++ b/tests/physics/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME physics-tests) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared) diff --git a/tests/shared/CMakeLists.txt b/tests/shared/CMakeLists.txt index bea8448f5e..828559936b 100644 --- a/tests/shared/CMakeLists.txt +++ b/tests/shared/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME shared-tests) -setup_hifi_project(${TARGET_NAME} TRUE) +setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared) diff --git a/tools/bitstream2json/CMakeLists.txt b/tools/bitstream2json/CMakeLists.txt index 3b3a65c259..a5077dc181 100644 --- a/tools/bitstream2json/CMakeLists.txt +++ b/tools/bitstream2json/CMakeLists.txt @@ -1,2 +1,2 @@ set(TARGET_NAME bitstream2json) -setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) \ No newline at end of file diff --git a/tools/json2bitstream/CMakeLists.txt b/tools/json2bitstream/CMakeLists.txt index 452f845356..28c18f6762 100644 --- a/tools/json2bitstream/CMakeLists.txt +++ b/tools/json2bitstream/CMakeLists.txt @@ -1,2 +1,2 @@ set(TARGET_NAME json2bitstream) -setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) \ No newline at end of file diff --git a/tools/mtc/CMakeLists.txt b/tools/mtc/CMakeLists.txt index 467d03d241..0b1c438393 100644 --- a/tools/mtc/CMakeLists.txt +++ b/tools/mtc/CMakeLists.txt @@ -1,2 +1,2 @@ set(TARGET_NAME mtc) -setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) \ No newline at end of file diff --git a/voxel-edit/CMakeLists.txt b/voxel-edit/CMakeLists.txt index db22f040b7..5fa4061117 100644 --- a/voxel-edit/CMakeLists.txt +++ b/voxel-edit/CMakeLists.txt @@ -1,3 +1,3 @@ set(TARGET_NAME voxel-edit) -setup_hifi_project(${TARGET_NAME} TRUE) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) \ No newline at end of file From e4d01d269c9d53739a0b315ce78adcaba15e1ffb Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 11:51:12 -0700 Subject: [PATCH 22/43] use shared dependency linking macro in hifi projects --- domain-server/CMakeLists.txt | 9 +++++---- interface/CMakeLists.txt | 3 +++ tests/audio/CMakeLists.txt | 5 ++++- tests/jitter/CMakeLists.txt | 5 ++++- tests/metavoxels/CMakeLists.txt | 8 +++----- tests/networking/CMakeLists.txt | 2 ++ tests/octree/CMakeLists.txt | 5 ++--- tests/physics/CMakeLists.txt | 2 ++ tests/shared/CMakeLists.txt | 3 +++ tools/bitstream2json/CMakeLists.txt | 5 ++++- tools/mtc/CMakeLists.txt | 5 ++++- voxel-edit/CMakeLists.txt | 5 ++++- 12 files changed, 40 insertions(+), 17 deletions(-) diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 3c1d34ba01..99e57cb0e6 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -1,6 +1,7 @@ set(TARGET_NAME domain-server) -setup_hifi_project(${TARGET_NAME}) +# setup the project and link required Qt modules +setup_hifi_project(${TARGET_NAME} Network) # remove and then copy the files for the webserver add_custom_command(TARGET ${TARGET_NAME} POST_BUILD @@ -11,8 +12,8 @@ add_custom_command(TARGET ${TARGET_NAME} POST_BUILD "${PROJECT_SOURCE_DIR}/resources/web" $/resources/web) -# link the shared hifi library +# link the shared hifi libraries link_hifi_libraries(${TARGET_NAME} embedded-webserver networking shared) -find_package(Qt5 COMPONENTS Network Widgets) -target_link_libraries(${TARGET_NAME} Qt5::Network) +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index ea4b54257b..a2770943a7 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -209,3 +209,6 @@ else (APPLE) target_link_libraries(${TARGET_NAME} "${GLEW_LIBRARIES}" wsock32.lib opengl32.lib) endif() endif (APPLE) + +# link any dependencies bubbled up from our linked dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index f5d9388508..973726852d 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -6,4 +6,7 @@ setup_hifi_project(${TARGET_NAME}) include_glm(${TARGET_NAME} ${ROOT_DIR}) # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared audio networking) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} shared audio networking) + +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/jitter/CMakeLists.txt b/tests/jitter/CMakeLists.txt index 9c861eac3e..577591227f 100644 --- a/tests/jitter/CMakeLists.txt +++ b/tests/jitter/CMakeLists.txt @@ -3,4 +3,7 @@ set(TARGET_NAME jitter-tests) setup_hifi_project(${TARGET_NAME}) # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared networking) \ No newline at end of file +link_hifi_libraries(${TARGET_NAME} shared networking) + +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/metavoxels/CMakeLists.txt b/tests/metavoxels/CMakeLists.txt index 358a959eb0..6432b9a259 100644 --- a/tests/metavoxels/CMakeLists.txt +++ b/tests/metavoxels/CMakeLists.txt @@ -1,13 +1,11 @@ set(TARGET_NAME metavoxel-tests) -find_package(Qt5 COMPONENTS Network Script Widgets) - auto_mtc(${TARGET_NAME} "${ROOT_DIR}") -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project(${TARGET_NAME} Network Script Widgets) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} metavoxels networking shared) -target_link_libraries(${TARGET_NAME} Qt5::Network Qt5::Widgets Qt5::Script) - +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/networking/CMakeLists.txt b/tests/networking/CMakeLists.txt index 68de37a1d2..214b66fd1f 100644 --- a/tests/networking/CMakeLists.txt +++ b/tests/networking/CMakeLists.txt @@ -5,3 +5,5 @@ setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared networking) +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index a8e27e0084..e9a06bd1c1 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -5,6 +5,5 @@ setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} octree) -IF (WIN32) - target_link_libraries(${TARGET_NAME} wsock32.lib) -ENDIF(WIN32) +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/physics/CMakeLists.txt b/tests/physics/CMakeLists.txt index 01bdf5a96b..74049b158b 100644 --- a/tests/physics/CMakeLists.txt +++ b/tests/physics/CMakeLists.txt @@ -5,3 +5,5 @@ setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared) +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/shared/CMakeLists.txt b/tests/shared/CMakeLists.txt index 828559936b..294a60d130 100644 --- a/tests/shared/CMakeLists.txt +++ b/tests/shared/CMakeLists.txt @@ -4,3 +4,6 @@ setup_hifi_project(${TARGET_NAME}) # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared) + +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tools/bitstream2json/CMakeLists.txt b/tools/bitstream2json/CMakeLists.txt index a5077dc181..884f9f9c2c 100644 --- a/tools/bitstream2json/CMakeLists.txt +++ b/tools/bitstream2json/CMakeLists.txt @@ -1,2 +1,5 @@ set(TARGET_NAME bitstream2json) -setup_hifi_project(${TARGET_NAME}) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) + +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tools/mtc/CMakeLists.txt b/tools/mtc/CMakeLists.txt index 0b1c438393..dc30da8098 100644 --- a/tools/mtc/CMakeLists.txt +++ b/tools/mtc/CMakeLists.txt @@ -1,2 +1,5 @@ set(TARGET_NAME mtc) -setup_hifi_project(${TARGET_NAME}) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) + +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/voxel-edit/CMakeLists.txt b/voxel-edit/CMakeLists.txt index 5fa4061117..f9f8ed185b 100644 --- a/voxel-edit/CMakeLists.txt +++ b/voxel-edit/CMakeLists.txt @@ -1,3 +1,6 @@ set(TARGET_NAME voxel-edit) -setup_hifi_project(${TARGET_NAME}) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) + +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file From 0449660f66adf279ef09e0e74dd3a0ffaa33fe2c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 11:52:41 -0700 Subject: [PATCH 23/43] don't bubble up hifi libraries since they are static --- cmake/macros/LinkHifiLibraries.cmake | 4 ++-- tools/json2bitstream/CMakeLists.txt | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/macros/LinkHifiLibraries.cmake b/cmake/macros/LinkHifiLibraries.cmake index 96c5d82cae..00020cc059 100644 --- a/cmake/macros/LinkHifiLibraries.cmake +++ b/cmake/macros/LinkHifiLibraries.cmake @@ -22,8 +22,8 @@ macro(LINK_HIFI_LIBRARIES TARGET) add_dependencies(${TARGET} ${HIFI_LIBRARY}) - # link the actual library - list(APPEND ${TARGET}_LIBRARIES_TO_LINK ${HIFI_LIBRARY}) + # link the actual library - it is static so don't bubble it up + target_link_libraries(${TARGET} ${HIFI_LIBRARY}) # ask the library what its dynamic dependencies are and link them get_target_property(LINKED_TARGET_DEPENDENCY_LIBRARIES ${HIFI_LIBRARY} DEPENDENCY_LIBRARIES) diff --git a/tools/json2bitstream/CMakeLists.txt b/tools/json2bitstream/CMakeLists.txt index 28c18f6762..3868b551ea 100644 --- a/tools/json2bitstream/CMakeLists.txt +++ b/tools/json2bitstream/CMakeLists.txt @@ -1,2 +1,5 @@ set(TARGET_NAME json2bitstream) -setup_hifi_project(${TARGET_NAME}) \ No newline at end of file +setup_hifi_project(${TARGET_NAME}) + +# link any shared dependencies +link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file From 27419b7b6b9b8b7bbb089f771ac07419159e6ae1 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 12:41:41 -0700 Subject: [PATCH 24/43] fix some build blockers in test directory --- libraries/shared/src/MovingMinMaxAvg.h | 1 + tests/metavoxels/CMakeLists.txt | 2 ++ tests/networking/src/SequenceNumberStatsTests.cpp | 7 ++++--- tests/octree/CMakeLists.txt | 6 ++++-- tests/physics/CMakeLists.txt | 2 ++ tests/shared/CMakeLists.txt | 2 ++ 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/libraries/shared/src/MovingMinMaxAvg.h b/libraries/shared/src/MovingMinMaxAvg.h index 734018b469..7d4b3df124 100644 --- a/libraries/shared/src/MovingMinMaxAvg.h +++ b/libraries/shared/src/MovingMinMaxAvg.h @@ -12,6 +12,7 @@ #ifndef hifi_MovingMinMaxAvg_h #define hifi_MovingMinMaxAvg_h +#include #include #include "RingBufferHistory.h" diff --git a/tests/metavoxels/CMakeLists.txt b/tests/metavoxels/CMakeLists.txt index 6432b9a259..0fad728764 100644 --- a/tests/metavoxels/CMakeLists.txt +++ b/tests/metavoxels/CMakeLists.txt @@ -2,6 +2,8 @@ set(TARGET_NAME metavoxel-tests) auto_mtc(${TARGET_NAME} "${ROOT_DIR}") +include_glm(${TARGET_NAME}) + setup_hifi_project(${TARGET_NAME} Network Script Widgets) # link in the shared libraries diff --git a/tests/networking/src/SequenceNumberStatsTests.cpp b/tests/networking/src/SequenceNumberStatsTests.cpp index 901a018235..ded67b1ab6 100644 --- a/tests/networking/src/SequenceNumberStatsTests.cpp +++ b/tests/networking/src/SequenceNumberStatsTests.cpp @@ -9,11 +9,12 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -#include "SequenceNumberStatsTests.h" - -#include "SharedUtil.h" +#include #include +#include + +#include "SequenceNumberStatsTests.h" void SequenceNumberStatsTests::runAllTests() { rolloverTest(); diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index e9a06bd1c1..baae258643 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -1,9 +1,11 @@ set(TARGET_NAME octree-tests) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project(${TARGET_NAME} Script Network) + +include_glm(${TARGET_NAME}) # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} octree) +link_hifi_libraries(${TARGET_NAME} animation fbx models networking octree shared) # link any shared dependencies link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file diff --git a/tests/physics/CMakeLists.txt b/tests/physics/CMakeLists.txt index 74049b158b..e2affa7b47 100644 --- a/tests/physics/CMakeLists.txt +++ b/tests/physics/CMakeLists.txt @@ -2,6 +2,8 @@ set(TARGET_NAME physics-tests) setup_hifi_project(${TARGET_NAME}) +include_glm(${TARGET_NAME}) + # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared) diff --git a/tests/shared/CMakeLists.txt b/tests/shared/CMakeLists.txt index 294a60d130..f819a2734b 100644 --- a/tests/shared/CMakeLists.txt +++ b/tests/shared/CMakeLists.txt @@ -2,6 +2,8 @@ set(TARGET_NAME shared-tests) setup_hifi_project(${TARGET_NAME}) +include_glm(${TARGET_NAME}) + # link in the shared libraries link_hifi_libraries(${TARGET_NAME} shared) From b1310c065ce7e37d1c61026e53614b99207d6311 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 12:55:06 -0700 Subject: [PATCH 25/43] remove TARGET_NAME from cmake macros where it is not required --- assignment-client/CMakeLists.txt | 8 ++++---- cmake/macros/AutoMTC.cmake | 4 ++-- cmake/macros/IncludeGLM.cmake | 4 ++-- cmake/macros/LinkHifiLibraries.cmake | 10 +++++----- ...ToTarget.cmake => LinkSharedDependencies.cmake} | 14 +++++++------- cmake/macros/SetupHifiLibrary.cmake | 12 ++++++------ cmake/macros/SetupHifiProject.cmake | 10 +++++----- domain-server/CMakeLists.txt | 6 +++--- interface/CMakeLists.txt | 6 +++--- libraries/animation/CMakeLists.txt | 6 +++--- libraries/audio/CMakeLists.txt | 8 ++++---- libraries/avatars/CMakeLists.txt | 8 ++++---- libraries/embedded-webserver/CMakeLists.txt | 4 ++-- libraries/fbx/CMakeLists.txt | 8 ++++---- libraries/metavoxels/CMakeLists.txt | 10 +++++----- libraries/models/CMakeLists.txt | 8 ++++---- libraries/networking/CMakeLists.txt | 6 +++--- libraries/octree/CMakeLists.txt | 8 ++++---- libraries/particles/CMakeLists.txt | 8 ++++---- libraries/script-engine/CMakeLists.txt | 8 ++++---- libraries/shared/CMakeLists.txt | 4 ++-- libraries/voxels/CMakeLists.txt | 8 ++++---- tests/audio/CMakeLists.txt | 9 ++++----- tests/jitter/CMakeLists.txt | 6 +++--- tests/metavoxels/CMakeLists.txt | 10 +++++----- tests/networking/CMakeLists.txt | 6 +++--- tests/octree/CMakeLists.txt | 8 ++++---- tests/physics/CMakeLists.txt | 8 ++++---- tests/shared/CMakeLists.txt | 8 ++++---- tools/bitstream2json/CMakeLists.txt | 4 ++-- tools/json2bitstream/CMakeLists.txt | 4 ++-- tools/mtc/CMakeLists.txt | 4 ++-- voxel-edit/CMakeLists.txt | 4 ++-- 33 files changed, 119 insertions(+), 120 deletions(-) rename cmake/macros/{LinkSharedDependenciesToTarget.cmake => LinkSharedDependencies.cmake} (61%) diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 9f8542c42e..972c6ac220 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME assignment-client) -setup_hifi_project(${TARGET_NAME} Core Gui Network Script Widgets) +setup_hifi_project(Core Gui Network Script Widgets) -include_glm(${TARGET_NAME}) +include_glm() # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} +link_hifi_libraries( audio avatars octree voxels fbx particles models metavoxels networking animation shared script-engine embedded-webserver ) @@ -14,4 +14,4 @@ if (UNIX) list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK ${CMAKE_DL_LIBS}) endif (UNIX) -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/cmake/macros/AutoMTC.cmake b/cmake/macros/AutoMTC.cmake index 0e376fc176..4d433e7b69 100644 --- a/cmake/macros/AutoMTC.cmake +++ b/cmake/macros/AutoMTC.cmake @@ -8,8 +8,8 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(AUTO_MTC TARGET) - set(AUTOMTC_SRC ${TARGET}_automtc.cpp) +macro(AUTO_MTC) + set(AUTOMTC_SRC ${TARGET_NAME}_automtc.cpp) file(GLOB INCLUDE_FILES src/*.h) diff --git a/cmake/macros/IncludeGLM.cmake b/cmake/macros/IncludeGLM.cmake index ec7816770f..e2fa981a3b 100644 --- a/cmake/macros/IncludeGLM.cmake +++ b/cmake/macros/IncludeGLM.cmake @@ -7,7 +7,7 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(INCLUDE_GLM TARGET) +macro(INCLUDE_GLM) find_package(GLM REQUIRED) include_directories("${GLM_INCLUDE_DIRS}") @@ -16,4 +16,4 @@ macro(INCLUDE_GLM TARGET) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${GLM_INCLUDE_DIRS}") endif () -endmacro(INCLUDE_GLM _target) \ No newline at end of file +endmacro(INCLUDE_GLM) \ No newline at end of file diff --git a/cmake/macros/LinkHifiLibraries.cmake b/cmake/macros/LinkHifiLibraries.cmake index 00020cc059..9d73963fea 100644 --- a/cmake/macros/LinkHifiLibraries.cmake +++ b/cmake/macros/LinkHifiLibraries.cmake @@ -7,7 +7,7 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(LINK_HIFI_LIBRARIES TARGET) +macro(LINK_HIFI_LIBRARIES) file(RELATIVE_PATH RELATIVE_LIBRARY_DIR_PATH ${CMAKE_CURRENT_SOURCE_DIR} "${HIFI_LIBRARY_DIR}") @@ -20,15 +20,15 @@ macro(LINK_HIFI_LIBRARIES TARGET) include_directories("${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src") - add_dependencies(${TARGET} ${HIFI_LIBRARY}) + add_dependencies(${TARGET_NAME} ${HIFI_LIBRARY}) # link the actual library - it is static so don't bubble it up - target_link_libraries(${TARGET} ${HIFI_LIBRARY}) + target_link_libraries(${TARGET_NAME} ${HIFI_LIBRARY}) # ask the library what its dynamic dependencies are and link them get_target_property(LINKED_TARGET_DEPENDENCY_LIBRARIES ${HIFI_LIBRARY} DEPENDENCY_LIBRARIES) - list(APPEND ${TARGET}_LIBRARIES_TO_LINK ${LINKED_TARGET_DEPENDENCY_LIBRARIES}) + list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK ${LINKED_TARGET_DEPENDENCY_LIBRARIES}) endforeach() -endmacro(LINK_HIFI_LIBRARIES _target _libraries) \ No newline at end of file +endmacro(LINK_HIFI_LIBRARIES) \ No newline at end of file diff --git a/cmake/macros/LinkSharedDependenciesToTarget.cmake b/cmake/macros/LinkSharedDependencies.cmake similarity index 61% rename from cmake/macros/LinkSharedDependenciesToTarget.cmake rename to cmake/macros/LinkSharedDependencies.cmake index 42f7109807..ae478ca530 100644 --- a/cmake/macros/LinkSharedDependenciesToTarget.cmake +++ b/cmake/macros/LinkSharedDependencies.cmake @@ -1,5 +1,5 @@ # -# LinkHifiLibrary.cmake +# LinkSharedDependencies.cmake # cmake/macros # # Copyright 2014 High Fidelity, Inc. @@ -9,17 +9,17 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(LINK_SHARED_DEPENDENCIES_TO_TARGET TARGET) - if (${TARGET}_LIBRARIES_TO_LINK) - list(REMOVE_DUPLICATES ${TARGET}_LIBRARIES_TO_LINK) +macro(LINK_SHARED_DEPENDENCIES) + if (${TARGET_NAME}_LIBRARIES_TO_LINK) + list(REMOVE_DUPLICATES ${TARGET_NAME}_LIBRARIES_TO_LINK) # link these libraries to our target - target_link_libraries(${TARGET} ${${TARGET}_LIBRARIES_TO_LINK}) + target_link_libraries(${TARGET_NAME} ${${TARGET_NAME}_LIBRARIES_TO_LINK}) endif () # we've already linked our Qt modules, but we need to bubble them up to parents - list(APPEND ${TARGET}_LIBRARIES_TO_LINK "${${TARGET}_QT_MODULES_TO_LINK}") + list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${${TARGET}_QT_MODULES_TO_LINK}") # set the property on this target so it can be retreived by targets linking to us set_target_properties(${TARGET_NAME} PROPERTIES DEPENDENCY_LIBRARIES "${${TARGET}_LIBRARIES_TO_LINK}") -endmacro(LINK_SHARED_DEPENDENCIES_TO_TARGET _target) \ No newline at end of file +endmacro(LINK_SHARED_DEPENDENCIES) \ No newline at end of file diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index 73ee208b98..3c2590d38d 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -7,16 +7,16 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(SETUP_HIFI_LIBRARY TARGET) +macro(SETUP_HIFI_LIBRARY) - project(${TARGET}) + project(${TARGET_NAME}) # grab the implemenation and header files file(GLOB LIB_SRCS src/*.h src/*.cpp) set(LIB_SRCS ${LIB_SRCS}) # create a library and set the property so it can be referenced later - add_library(${TARGET} ${LIB_SRCS} ${AUTOMTC_SRC}) + add_library(${TARGET_NAME} ${LIB_SRCS} ${AUTOMTC_SRC}) set(QT_MODULES_TO_LINK ${ARGN}) list(APPEND QT_MODULES_TO_LINK Core) @@ -27,7 +27,7 @@ macro(SETUP_HIFI_LIBRARY TARGET) get_target_property(QT_LIBRARY_LOCATION Qt5::${QT_MODULE} LOCATION) # add the actual path to the Qt module to our LIBRARIES_TO_LINK variable - target_link_libraries(${TARGET} Qt5::${QT_MODULE}) - list(APPEND ${TARGET}_QT_MODULES_TO_LINK ${QT_LIBRARY_LOCATION}) + target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE}) + list(APPEND ${TARGET_NAME}_QT_MODULES_TO_LINK ${QT_LIBRARY_LOCATION}) endforeach() -endmacro(SETUP_HIFI_LIBRARY _target) \ No newline at end of file +endmacro(SETUP_HIFI_LIBRARY) \ No newline at end of file diff --git a/cmake/macros/SetupHifiProject.cmake b/cmake/macros/SetupHifiProject.cmake index c680790f02..62c215e595 100644 --- a/cmake/macros/SetupHifiProject.cmake +++ b/cmake/macros/SetupHifiProject.cmake @@ -7,8 +7,8 @@ # See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html # -macro(SETUP_HIFI_PROJECT TARGET) - project(${TARGET}) +macro(SETUP_HIFI_PROJECT) + project(${TARGET_NAME}) # grab the implemenation and header files file(GLOB TARGET_SRCS src/*) @@ -23,7 +23,7 @@ macro(SETUP_HIFI_PROJECT TARGET) endforeach() # add the executable, include additional optional sources - add_executable(${TARGET} ${TARGET_SRCS} "${AUTOMTC_SRC}") + add_executable(${TARGET_NAME} ${TARGET_SRCS} "${AUTOMTC_SRC}") set(QT_MODULES_TO_LINK ${ARGN}) list(APPEND QT_MODULES_TO_LINK Core) @@ -31,11 +31,11 @@ macro(SETUP_HIFI_PROJECT TARGET) find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK}) foreach(QT_MODULE ${QT_MODULES_TO_LINK}) - target_link_libraries(${TARGET} Qt5::${QT_MODULE}) + target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE}) # add the actual path to the Qt module to our LIBRARIES_TO_LINK variable get_target_property(QT_LIBRARY_LOCATION Qt5::${QT_MODULE} LOCATION) - list(APPEND ${TARGET}_QT_MODULES_TO_LINK ${QT_LIBRARY_LOCATION}) + list(APPEND ${TARGET_NAME}_QT_MODULES_TO_LINK ${QT_LIBRARY_LOCATION}) endforeach() endmacro() \ No newline at end of file diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 99e57cb0e6..bc9269b9ce 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -1,7 +1,7 @@ set(TARGET_NAME domain-server) # setup the project and link required Qt modules -setup_hifi_project(${TARGET_NAME} Network) +setup_hifi_project(Network) # remove and then copy the files for the webserver add_custom_command(TARGET ${TARGET_NAME} POST_BUILD @@ -13,7 +13,7 @@ add_custom_command(TARGET ${TARGET_NAME} POST_BUILD $/resources/web) # link the shared hifi libraries -link_hifi_libraries(${TARGET_NAME} embedded-webserver networking shared) +link_hifi_libraries(embedded-webserver networking shared) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index a2770943a7..d58bea6f9e 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -32,7 +32,7 @@ elseif (WIN32) endif () # set up the external glm library -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() # create the InterfaceConfig.h file based on GL_HEADERS above configure_file(InterfaceConfig.h.in "${PROJECT_BINARY_DIR}/includes/InterfaceConfig.h") @@ -91,7 +91,7 @@ endif() add_executable(${TARGET_NAME} MACOSX_BUNDLE ${INTERFACE_SRCS} ${QM}) # link required hifi libraries -link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx metavoxels networking particles models avatars audio animation script-engine) +link_hifi_libraries(shared octree voxels fbx metavoxels networking particles models avatars audio animation script-engine) # find any optional and required libraries find_package(Faceplus) @@ -211,4 +211,4 @@ else (APPLE) endif (APPLE) # link any dependencies bubbled up from our linked dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) +link_shared_dependencies() diff --git a/libraries/animation/CMakeLists.txt b/libraries/animation/CMakeLists.txt index 19fa087092..3f65c1ab6c 100644 --- a/libraries/animation/CMakeLists.txt +++ b/libraries/animation/CMakeLists.txt @@ -1,9 +1,9 @@ set(TARGET_NAME animation) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network Script) +setup_hifi_library(Network Script) -link_hifi_libraries(${TARGET_NAME} shared fbx) +link_hifi_libraries(shared fbx) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/audio/CMakeLists.txt b/libraries/audio/CMakeLists.txt index 8487f48ad3..6ade1fc423 100644 --- a/libraries/audio/CMakeLists.txt +++ b/libraries/audio/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME audio) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network) +setup_hifi_library(Network) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() -link_hifi_libraries(${TARGET_NAME} networking shared) +link_hifi_libraries(networking shared) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/avatars/CMakeLists.txt b/libraries/avatars/CMakeLists.txt index 2791589abb..1d287ee7a2 100644 --- a/libraries/avatars/CMakeLists.txt +++ b/libraries/avatars/CMakeLists.txt @@ -1,12 +1,12 @@ set(TARGET_NAME avatars) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network Script) +setup_hifi_library(Network Script) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() -link_hifi_libraries(${TARGET_NAME} shared octree voxels networking) +link_hifi_libraries(shared octree voxels networking) include_hifi_library_headers(fbx) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/embedded-webserver/CMakeLists.txt b/libraries/embedded-webserver/CMakeLists.txt index b397003133..6e4b92e217 100644 --- a/libraries/embedded-webserver/CMakeLists.txt +++ b/libraries/embedded-webserver/CMakeLists.txt @@ -1,7 +1,7 @@ set(TARGET_NAME embedded-webserver) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network) +setup_hifi_library(Network) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index d02cc918fc..3cc510aed9 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -1,15 +1,15 @@ set(TARGET_NAME fbx) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME}) +setup_hifi_library() -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm("${ROOT_DIR}") -link_hifi_libraries(${TARGET_NAME} shared networking octree voxels) +link_hifi_libraries(shared networking octree voxels) find_package(ZLIB) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) +link_shared_dependencies() diff --git a/libraries/metavoxels/CMakeLists.txt b/libraries/metavoxels/CMakeLists.txt index b9a03bf0f4..aab8d2184d 100644 --- a/libraries/metavoxels/CMakeLists.txt +++ b/libraries/metavoxels/CMakeLists.txt @@ -1,14 +1,14 @@ set(TARGET_NAME metavoxels) -auto_mtc(${TARGET_NAME} "${ROOT_DIR}") +auto_mtc() # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network Script Widgets) +setup_hifi_library(Network Script Widgets) # link in the networking library -link_hifi_libraries(${TARGET_NAME} shared networking) +link_hifi_libraries(shared networking) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/models/CMakeLists.txt b/libraries/models/CMakeLists.txt index 89178f193a..858d01efa1 100644 --- a/libraries/models/CMakeLists.txt +++ b/libraries/models/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME models) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network Script) +setup_hifi_library(Network Script) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() -link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) +link_hifi_libraries(shared octree fbx networking animation) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index c2b86e2218..3191cfe67b 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -1,9 +1,9 @@ set(TARGET_NAME networking) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network) +setup_hifi_library(Network) -link_hifi_libraries(${TARGET_NAME} shared) +link_hifi_libraries(shared) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index 1fa730aad7..193b058466 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME octree) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME}) +setup_hifi_library() -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() -link_hifi_libraries(${TARGET_NAME} shared networking) +link_hifi_libraries(shared networking) # find ZLIB and OpenSSL find_package(ZLIB) @@ -18,4 +18,4 @@ list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${OPENSSL_LIBRARIES}") # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/particles/CMakeLists.txt b/libraries/particles/CMakeLists.txt index f306c0a749..27fc816530 100644 --- a/libraries/particles/CMakeLists.txt +++ b/libraries/particles/CMakeLists.txt @@ -1,12 +1,12 @@ set(TARGET_NAME particles) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Gui Network Script) +setup_hifi_library(Gui Network Script) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() -link_hifi_libraries(${TARGET_NAME} shared octree fbx networking animation) +link_hifi_libraries(shared octree fbx networking animation) include_hifi_library_headers(script-engine) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/script-engine/CMakeLists.txt b/libraries/script-engine/CMakeLists.txt index a16d6270c9..dd28e77b7e 100644 --- a/libraries/script-engine/CMakeLists.txt +++ b/libraries/script-engine/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME script-engine) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Gui Network Script Widgets) +setup_hifi_library(Gui Network Script Widgets) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() -link_hifi_libraries(${TARGET_NAME} shared octree voxels fbx particles models animation) +link_hifi_libraries(shared octree voxels fbx particles models animation) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/shared/CMakeLists.txt b/libraries/shared/CMakeLists.txt index 1a6b39ea59..17ccbdc6ce 100644 --- a/libraries/shared/CMakeLists.txt +++ b/libraries/shared/CMakeLists.txt @@ -1,7 +1,7 @@ set(TARGET_NAME shared) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Network Widgets) +setup_hifi_library(Network Widgets) # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/libraries/voxels/CMakeLists.txt b/libraries/voxels/CMakeLists.txt index 87841ca29f..d9d8717fba 100644 --- a/libraries/voxels/CMakeLists.txt +++ b/libraries/voxels/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME voxels) # use setup_hifi_library macro to setup our project and link appropriate Qt modules -setup_hifi_library(${TARGET_NAME} Widgets Script) +setup_hifi_library(Widgets Script) -include_glm(${TARGET_NAME} "${ROOT_DIR}") +include_glm() -link_hifi_libraries(${TARGET_NAME} shared octree networking) +link_hifi_libraries(shared octree networking) # find ZLIB find_package(ZLIB) @@ -15,4 +15,4 @@ include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") list(APPEND ${TARGET}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") # call macro to link our dependencies and bubble them up via a property on our target -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index 973726852d..3ef87ede28 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -1,12 +1,11 @@ set(TARGET_NAME audio-tests) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() -#include glm -include_glm(${TARGET_NAME} ${ROOT_DIR}) +include_glm() # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared audio networking) +link_hifi_libraries(shared audio networking) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tests/jitter/CMakeLists.txt b/tests/jitter/CMakeLists.txt index 577591227f..28a312540f 100644 --- a/tests/jitter/CMakeLists.txt +++ b/tests/jitter/CMakeLists.txt @@ -1,9 +1,9 @@ set(TARGET_NAME jitter-tests) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared networking) +link_hifi_libraries(shared networking) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tests/metavoxels/CMakeLists.txt b/tests/metavoxels/CMakeLists.txt index 0fad728764..53b6da4301 100644 --- a/tests/metavoxels/CMakeLists.txt +++ b/tests/metavoxels/CMakeLists.txt @@ -1,13 +1,13 @@ set(TARGET_NAME metavoxel-tests) -auto_mtc(${TARGET_NAME} "${ROOT_DIR}") +auto_mtc() -include_glm(${TARGET_NAME}) +include_glm() -setup_hifi_project(${TARGET_NAME} Network Script Widgets) +setup_hifi_project(Network Script Widgets) # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} metavoxels networking shared) +link_hifi_libraries(metavoxels networking shared) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tests/networking/CMakeLists.txt b/tests/networking/CMakeLists.txt index 214b66fd1f..28fdb539b7 100644 --- a/tests/networking/CMakeLists.txt +++ b/tests/networking/CMakeLists.txt @@ -1,9 +1,9 @@ set(TARGET_NAME networking-tests) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared networking) +link_hifi_libraries(shared networking) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index baae258643..b59344f7f0 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME octree-tests) -setup_hifi_project(${TARGET_NAME} Script Network) +setup_hifi_project(Script Network) -include_glm(${TARGET_NAME}) +include_glm() # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} animation fbx models networking octree shared) +link_hifi_libraries(animation fbx models networking octree shared) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tests/physics/CMakeLists.txt b/tests/physics/CMakeLists.txt index e2affa7b47..c2c9327fa0 100644 --- a/tests/physics/CMakeLists.txt +++ b/tests/physics/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME physics-tests) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() -include_glm(${TARGET_NAME}) +include_glm() # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared) +link_hifi_libraries(shared) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tests/shared/CMakeLists.txt b/tests/shared/CMakeLists.txt index f819a2734b..8fa2a1c3c4 100644 --- a/tests/shared/CMakeLists.txt +++ b/tests/shared/CMakeLists.txt @@ -1,11 +1,11 @@ set(TARGET_NAME shared-tests) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() -include_glm(${TARGET_NAME}) +include_glm() # link in the shared libraries -link_hifi_libraries(${TARGET_NAME} shared) +link_hifi_libraries(shared) # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tools/bitstream2json/CMakeLists.txt b/tools/bitstream2json/CMakeLists.txt index 884f9f9c2c..5cf833eaef 100644 --- a/tools/bitstream2json/CMakeLists.txt +++ b/tools/bitstream2json/CMakeLists.txt @@ -1,5 +1,5 @@ set(TARGET_NAME bitstream2json) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tools/json2bitstream/CMakeLists.txt b/tools/json2bitstream/CMakeLists.txt index 3868b551ea..d8619d95a3 100644 --- a/tools/json2bitstream/CMakeLists.txt +++ b/tools/json2bitstream/CMakeLists.txt @@ -1,5 +1,5 @@ set(TARGET_NAME json2bitstream) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/tools/mtc/CMakeLists.txt b/tools/mtc/CMakeLists.txt index dc30da8098..2a530f3c66 100644 --- a/tools/mtc/CMakeLists.txt +++ b/tools/mtc/CMakeLists.txt @@ -1,5 +1,5 @@ set(TARGET_NAME mtc) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file diff --git a/voxel-edit/CMakeLists.txt b/voxel-edit/CMakeLists.txt index f9f8ed185b..fea2e27ab1 100644 --- a/voxel-edit/CMakeLists.txt +++ b/voxel-edit/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME voxel-edit) -setup_hifi_project(${TARGET_NAME}) +setup_hifi_project() # link any shared dependencies -link_shared_dependencies_to_target(${TARGET_NAME}) \ No newline at end of file +link_shared_dependencies() \ No newline at end of file From a99b19d28ac8757cf48cacff335aca3583f9516d Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 12:57:46 -0700 Subject: [PATCH 26/43] make Qt5 and ZLIB required finds, add OpenSSL to interface --- cmake/macros/SetupHifiLibrary.cmake | 2 +- cmake/macros/SetupHifiProject.cmake | 2 +- interface/CMakeLists.txt | 7 +++++-- libraries/fbx/CMakeLists.txt | 2 +- libraries/octree/CMakeLists.txt | 2 +- libraries/voxels/CMakeLists.txt | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cmake/macros/SetupHifiLibrary.cmake b/cmake/macros/SetupHifiLibrary.cmake index 3c2590d38d..7bb85f68f5 100644 --- a/cmake/macros/SetupHifiLibrary.cmake +++ b/cmake/macros/SetupHifiLibrary.cmake @@ -21,7 +21,7 @@ macro(SETUP_HIFI_LIBRARY) set(QT_MODULES_TO_LINK ${ARGN}) list(APPEND QT_MODULES_TO_LINK Core) - find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK}) + find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK} REQUIRED) foreach(QT_MODULE ${QT_MODULES_TO_LINK}) get_target_property(QT_LIBRARY_LOCATION Qt5::${QT_MODULE} LOCATION) diff --git a/cmake/macros/SetupHifiProject.cmake b/cmake/macros/SetupHifiProject.cmake index 62c215e595..d21e2c11bb 100644 --- a/cmake/macros/SetupHifiProject.cmake +++ b/cmake/macros/SetupHifiProject.cmake @@ -28,7 +28,7 @@ macro(SETUP_HIFI_PROJECT) set(QT_MODULES_TO_LINK ${ARGN}) list(APPEND QT_MODULES_TO_LINK Core) - find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK}) + find_package(Qt5 COMPONENTS ${QT_MODULES_TO_LINK} REQUIRED) foreach(QT_MODULE ${QT_MODULES_TO_LINK}) target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE}) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index d58bea6f9e..a042cfd1c1 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -102,10 +102,12 @@ find_package(SDL) find_package(Sixense) find_package(Visage) find_package(LeapMotion) -find_package(ZLIB) find_package(Qxmpp) find_package(RtMidi) +find_package(ZLIB REQUIRED) +find_package(OpenSSL REQUIRED) + # perform standard include and linking for found externals foreach(EXTERNAL ${OPTIONAL_EXTERNALS}) string(TOUPPER ${EXTERNAL} UPPER_EXTERNAL) @@ -157,9 +159,10 @@ endif () # include headers for interface and InterfaceConfig. include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes") +include_directories("${OPENSSL_INCLUDE_DIR}") target_link_libraries( - ${TARGET_NAME} "${ZLIB_LIBRARIES}" + ${TARGET_NAME} "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}" Qt5::Gui Qt5::Network Qt5::Multimedia Qt5::OpenGL Qt5::Script Qt5::Svg Qt5::WebKitWidgets ) diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index 3cc510aed9..794c6edbe6 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -7,7 +7,7 @@ include_glm("${ROOT_DIR}") link_hifi_libraries(shared networking octree voxels) -find_package(ZLIB) +find_package(ZLIB REQUIRED) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index 193b058466..da641d1524 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -8,7 +8,7 @@ include_glm() link_hifi_libraries(shared networking) # find ZLIB and OpenSSL -find_package(ZLIB) +find_package(ZLIB REQUIRED) find_package(OpenSSL REQUIRED) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") diff --git a/libraries/voxels/CMakeLists.txt b/libraries/voxels/CMakeLists.txt index d9d8717fba..3214978a2a 100644 --- a/libraries/voxels/CMakeLists.txt +++ b/libraries/voxels/CMakeLists.txt @@ -8,7 +8,7 @@ include_glm() link_hifi_libraries(shared octree networking) # find ZLIB -find_package(ZLIB) +find_package(ZLIB REQUIRED) include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") # add it to our list of libraries to link From 2fda95ae8fda3cfb7231d2d0c92dee33e9253f8a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 13:06:23 -0700 Subject: [PATCH 27/43] repair build of various tools --- domain-server/CMakeLists.txt | 1 - tests/audio/CMakeLists.txt | 1 - tests/jitter/CMakeLists.txt | 1 - tests/metavoxels/CMakeLists.txt | 1 - tests/networking/CMakeLists.txt | 1 - tests/octree/CMakeLists.txt | 1 - tests/physics/CMakeLists.txt | 1 - tests/shared/CMakeLists.txt | 1 - tools/bitstream2json/CMakeLists.txt | 7 +++++-- tools/json2bitstream/CMakeLists.txt | 7 +++++-- tools/mtc/CMakeLists.txt | 1 - voxel-edit/CMakeLists.txt | 5 ++++- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index bc9269b9ce..0fb9d25b5f 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -15,5 +15,4 @@ add_custom_command(TARGET ${TARGET_NAME} POST_BUILD # link the shared hifi libraries link_hifi_libraries(embedded-webserver networking shared) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tests/audio/CMakeLists.txt b/tests/audio/CMakeLists.txt index 3ef87ede28..974b4dcd09 100644 --- a/tests/audio/CMakeLists.txt +++ b/tests/audio/CMakeLists.txt @@ -7,5 +7,4 @@ include_glm() # link in the shared libraries link_hifi_libraries(shared audio networking) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tests/jitter/CMakeLists.txt b/tests/jitter/CMakeLists.txt index 28a312540f..d0b366e7ef 100644 --- a/tests/jitter/CMakeLists.txt +++ b/tests/jitter/CMakeLists.txt @@ -5,5 +5,4 @@ setup_hifi_project() # link in the shared libraries link_hifi_libraries(shared networking) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tests/metavoxels/CMakeLists.txt b/tests/metavoxels/CMakeLists.txt index 53b6da4301..732c974f95 100644 --- a/tests/metavoxels/CMakeLists.txt +++ b/tests/metavoxels/CMakeLists.txt @@ -9,5 +9,4 @@ setup_hifi_project(Network Script Widgets) # link in the shared libraries link_hifi_libraries(metavoxels networking shared) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tests/networking/CMakeLists.txt b/tests/networking/CMakeLists.txt index 28fdb539b7..a7293226b3 100644 --- a/tests/networking/CMakeLists.txt +++ b/tests/networking/CMakeLists.txt @@ -5,5 +5,4 @@ setup_hifi_project() # link in the shared libraries link_hifi_libraries(shared networking) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tests/octree/CMakeLists.txt b/tests/octree/CMakeLists.txt index b59344f7f0..5d37b51abe 100644 --- a/tests/octree/CMakeLists.txt +++ b/tests/octree/CMakeLists.txt @@ -7,5 +7,4 @@ include_glm() # link in the shared libraries link_hifi_libraries(animation fbx models networking octree shared) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tests/physics/CMakeLists.txt b/tests/physics/CMakeLists.txt index c2c9327fa0..96aaf48860 100644 --- a/tests/physics/CMakeLists.txt +++ b/tests/physics/CMakeLists.txt @@ -7,5 +7,4 @@ include_glm() # link in the shared libraries link_hifi_libraries(shared) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tests/shared/CMakeLists.txt b/tests/shared/CMakeLists.txt index 8fa2a1c3c4..fe3843e9eb 100644 --- a/tests/shared/CMakeLists.txt +++ b/tests/shared/CMakeLists.txt @@ -7,5 +7,4 @@ include_glm() # link in the shared libraries link_hifi_libraries(shared) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tools/bitstream2json/CMakeLists.txt b/tools/bitstream2json/CMakeLists.txt index 5cf833eaef..bc23a1e193 100644 --- a/tools/bitstream2json/CMakeLists.txt +++ b/tools/bitstream2json/CMakeLists.txt @@ -1,5 +1,8 @@ set(TARGET_NAME bitstream2json) -setup_hifi_project() +setup_hifi_project(Widgets Script) + +include_glm() + +link_hifi_libraries(metavoxels) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tools/json2bitstream/CMakeLists.txt b/tools/json2bitstream/CMakeLists.txt index d8619d95a3..91b56c18fd 100644 --- a/tools/json2bitstream/CMakeLists.txt +++ b/tools/json2bitstream/CMakeLists.txt @@ -1,5 +1,8 @@ set(TARGET_NAME json2bitstream) -setup_hifi_project() +setup_hifi_project(Widgets Script) + +include_glm() + +link_hifi_libraries(metavoxels) -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/tools/mtc/CMakeLists.txt b/tools/mtc/CMakeLists.txt index 2a530f3c66..4dfa8421ff 100644 --- a/tools/mtc/CMakeLists.txt +++ b/tools/mtc/CMakeLists.txt @@ -1,5 +1,4 @@ set(TARGET_NAME mtc) setup_hifi_project() -# link any shared dependencies link_shared_dependencies() \ No newline at end of file diff --git a/voxel-edit/CMakeLists.txt b/voxel-edit/CMakeLists.txt index fea2e27ab1..b61ee6d132 100644 --- a/voxel-edit/CMakeLists.txt +++ b/voxel-edit/CMakeLists.txt @@ -2,5 +2,8 @@ set(TARGET_NAME voxel-edit) setup_hifi_project() -# link any shared dependencies +include_glm() + +link_hifi_libraries(networking octree shared voxels) + link_shared_dependencies() \ No newline at end of file From 9d8818eee53287689dd01cfba42f1c4ea5faf278 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 13:18:32 -0700 Subject: [PATCH 28/43] remove OpenSSL requirement from octree library --- libraries/octree/CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libraries/octree/CMakeLists.txt b/libraries/octree/CMakeLists.txt index da641d1524..c302a082be 100644 --- a/libraries/octree/CMakeLists.txt +++ b/libraries/octree/CMakeLists.txt @@ -7,15 +7,13 @@ include_glm() link_hifi_libraries(shared networking) -# find ZLIB and OpenSSL +# find ZLIB find_package(ZLIB REQUIRED) -find_package(OpenSSL REQUIRED) -include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}" "${OPENSSL_INCLUDE_DIR}") +include_directories(SYSTEM "${ZLIB_INCLUDE_DIRS}") # append ZLIB and OpenSSL to our list of libraries to link list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${ZLIB_LIBRARIES}") -list(APPEND ${TARGET_NAME}_LIBRARIES_TO_LINK "${OPENSSL_LIBRARIES}") # call macro to link our dependencies and bubble them up via a property on our target link_shared_dependencies() \ No newline at end of file From 92b2fe6d68f17a0209df58a2712a34ad5e9ed0ae Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 13:22:00 -0700 Subject: [PATCH 29/43] remove ROOT_DIR param in include_glm, remove ROOT_DIR from root CMakeLists --- CMakeLists.txt | 4 ++-- libraries/fbx/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb54bcbd8a..28ff00cc96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,13 +44,13 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) # Instruct CMake to run moc automatically when needed. set(CMAKE_AUTOMOC ON) -set(ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(HIFI_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries") -set(MACRO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros") # setup for find modules set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/") +set(MACRO_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/macros") + file(GLOB HIFI_CUSTOM_MACROS "cmake/macros/*.cmake") foreach(CUSTOM_MACRO ${HIFI_CUSTOM_MACROS}) include(${CUSTOM_MACRO}) diff --git a/libraries/fbx/CMakeLists.txt b/libraries/fbx/CMakeLists.txt index 794c6edbe6..894fa14c33 100644 --- a/libraries/fbx/CMakeLists.txt +++ b/libraries/fbx/CMakeLists.txt @@ -3,7 +3,7 @@ set(TARGET_NAME fbx) # use setup_hifi_library macro to setup our project and link appropriate Qt modules setup_hifi_library() -include_glm("${ROOT_DIR}") +include_glm() link_hifi_libraries(shared networking octree voxels) From 6eb2c736247180a1cfdcdc955d9e10411b657264 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 13:23:54 -0700 Subject: [PATCH 30/43] add assert include to SharedUtil --- libraries/shared/src/SharedUtil.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/shared/src/SharedUtil.cpp b/libraries/shared/src/SharedUtil.cpp index 470dfffd13..ecf96e0190 100644 --- a/libraries/shared/src/SharedUtil.cpp +++ b/libraries/shared/src/SharedUtil.cpp @@ -9,6 +9,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include #include #include #include From d8dadc3199b83379361e26fc5060cdf6e4e26eff Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 13:31:09 -0700 Subject: [PATCH 31/43] link the socket library to the hifi networking library --- libraries/networking/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 3191cfe67b..501437fab2 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -5,5 +5,10 @@ setup_hifi_library(Network) link_hifi_libraries(shared) +if (WIN32) + # we need ws2_32.lib on windows, but it's static so we don't bubble it up + target_link_libraries(${TARGET_NAME} ws2_32.lib) +endif () + # call macro to link our dependencies and bubble them up via a property on our target link_shared_dependencies() \ No newline at end of file From 0dfbc8b8ba7288ddad1144c0726956561710c9a9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 13:32:34 -0700 Subject: [PATCH 32/43] add the xml library to QXMPP_LIBRARIES --- cmake/modules/FindQxmpp.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/modules/FindQxmpp.cmake b/cmake/modules/FindQxmpp.cmake index e5b6e6506a..3c0e97c998 100644 --- a/cmake/modules/FindQxmpp.cmake +++ b/cmake/modules/FindQxmpp.cmake @@ -26,10 +26,12 @@ find_path(QXMPP_INCLUDE_DIRS QXmppClient.h PATH_SUFFIXES include/qxmpp HINTS ${Q find_library(QXMPP_LIBRARY_RELEASE NAMES qxmpp PATH_SUFFIXES lib HINTS ${QXMPP_SEARCH_DIRS}) find_library(QXMPP_LIBRARY_DEBUG NAMES qxmpp_d PATH_SUFFIXES lib HINTS ${QXMPP_SEARCH_DIRS}) +find_package(Qt5 COMPONENTS Xml REQUIRED) + include(SelectLibraryConfigurations) select_library_configurations(QXMPP) -set(QXMPP_LIBRARIES "${QXMPP_LIBRARY}") +set(QXMPP_LIBRARIES "${QXMPP_LIBRARY}" Qt5::Xml) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(QXMPP DEFAULT_MSG QXMPP_INCLUDE_DIRS QXMPP_LIBRARIES) From 2badf9ab1a5d8fefa4c987b918c14d4f0ee38dc6 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 13:42:07 -0700 Subject: [PATCH 33/43] don't quote linked ZLIB and OpenSSL libs for interface --- interface/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index a042cfd1c1..82b102adf3 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -162,7 +162,7 @@ include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes" include_directories("${OPENSSL_INCLUDE_DIR}") target_link_libraries( - ${TARGET_NAME} "${ZLIB_LIBRARIES}" "${OPENSSL_LIBRARIES}" + ${TARGET_NAME} ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES} Qt5::Gui Qt5::Network Qt5::Multimedia Qt5::OpenGL Qt5::Script Qt5::Svg Qt5::WebKitWidgets ) From 234920b5bce2ccf4583a035ef380ad07c0269612 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 14:04:22 -0700 Subject: [PATCH 34/43] add QuartzCore to FindVisage module --- cmake/modules/FindVisage.cmake | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index 070905d6ff..36981827b1 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -32,6 +32,7 @@ if (APPLE) find_library(VISAGE_VISION_LIBRARY NAME vsvision PATH_SUFFIXES lib HINTS ${VISAGE_SEARCH_DIRS}) find_library(VISAGE_OPENCV_LIBRARY NAME OpenCV PATH_SUFFIXES dependencies/OpenCV_MacOSX/lib HINTS ${VISAGE_SEARCH_DIRS}) + find_library(QuartzCore QuartzCore) elseif (WIN32) find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h PATH_SUFFIXES dependencies/libxml2/include HINTS ${VISAGE_SEARCH_DIRS}) find_path(VISAGE_OPENCV_INCLUDE_DIR opencv/cv.h PATH_SUFFIXES dependencies/OpenCV/include HINTS ${VISAGE_SEARCH_DIRS}) @@ -43,14 +44,26 @@ elseif (WIN32) endif () include(FindPackageHandleStandardArgs) + +set(VISAGE_ARGS_LIST "VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR + VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR + VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY") + +if (APPLE) + list(APPEND VISAGE_ARGS_LIST QuartzCore) +endif () + find_package_handle_standard_args(VISAGE DEFAULT_MSG - VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR - VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY + VISAGE_ARGS_LIST ) set(VISAGE_INCLUDE_DIRS "${VISAGE_XML_INCLUDE_DIR}" "${VISAGE_OPENCV_INCLUDE_DIR}" "${VISAGE_OPENCV2_INCLUDE_DIR}" "${VISAGE_BASE_INCLUDE_DIR}") set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY}" "${VISAGE_VISION_LIBRARY}" "${VISAGE_OPENCV_LIBRARY}") +if (APPLE) + list(APPEND VISAGE_LIBRARIES ${QuartzCore}) +endif () + mark_as_advanced( VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR From e74c8f5e56a00c65c30b265852c4bd0620ff0abd Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 14:08:18 -0700 Subject: [PATCH 35/43] don't set visage find args list as quoted string --- cmake/modules/FindVisage.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index 36981827b1..d84bfbb69d 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -45,9 +45,9 @@ endif () include(FindPackageHandleStandardArgs) -set(VISAGE_ARGS_LIST "VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR +set(VISAGE_ARGS_LIST VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR - VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY") + VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY) if (APPLE) list(APPEND VISAGE_ARGS_LIST QuartzCore) From e638bbca3a766718981fe3ea54d658e65e379232 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 14:10:58 -0700 Subject: [PATCH 36/43] fix find package standard args call for visage --- cmake/modules/FindVisage.cmake | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index d84bfbb69d..6c8d4f5b76 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -45,17 +45,15 @@ endif () include(FindPackageHandleStandardArgs) -set(VISAGE_ARGS_LIST VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR +set(VISAGE_ARGS_LIST "VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR - VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY) + VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY") if (APPLE) list(APPEND VISAGE_ARGS_LIST QuartzCore) endif () -find_package_handle_standard_args(VISAGE DEFAULT_MSG - VISAGE_ARGS_LIST -) +find_package_handle_standard_args(VISAGE DEFAULT_MSG ${VISAGE_ARGS_LIST}) set(VISAGE_INCLUDE_DIRS "${VISAGE_XML_INCLUDE_DIR}" "${VISAGE_OPENCV_INCLUDE_DIR}" "${VISAGE_OPENCV2_INCLUDE_DIR}" "${VISAGE_BASE_INCLUDE_DIR}") set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY}" "${VISAGE_VISION_LIBRARY}" "${VISAGE_OPENCV_LIBRARY}") @@ -64,8 +62,4 @@ if (APPLE) list(APPEND VISAGE_LIBRARIES ${QuartzCore}) endif () -mark_as_advanced( - VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES - VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR - VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY VISAGE_SEARCH_DIRS -) +mark_as_advanced(VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES) From 2f6ff36d2239dfafc14bfb069cd38ef9114126e8 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 14:17:36 -0700 Subject: [PATCH 37/43] fix list of args for visage find module --- cmake/modules/FindVisage.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index 6c8d4f5b76..5c420fb0b5 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -45,9 +45,9 @@ endif () include(FindPackageHandleStandardArgs) -set(VISAGE_ARGS_LIST "VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR +list(APPEND VISAGE_ARGS_LIST VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_OPENCV_INCLUDE_DIR VISAGE_OPENCV2_INCLUDE_DIR - VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY") + VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY) if (APPLE) list(APPEND VISAGE_ARGS_LIST QuartzCore) From 36a3bc40d6d01988550dc4010b34376f83211aed Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 14:44:37 -0700 Subject: [PATCH 38/43] add AppKit to required Visage libraries --- cmake/modules/FindVisage.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index 5c420fb0b5..e2e66ec993 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -32,6 +32,7 @@ if (APPLE) find_library(VISAGE_VISION_LIBRARY NAME vsvision PATH_SUFFIXES lib HINTS ${VISAGE_SEARCH_DIRS}) find_library(VISAGE_OPENCV_LIBRARY NAME OpenCV PATH_SUFFIXES dependencies/OpenCV_MacOSX/lib HINTS ${VISAGE_SEARCH_DIRS}) + find_library(AppKit AppKit) find_library(QuartzCore QuartzCore) elseif (WIN32) find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h PATH_SUFFIXES dependencies/libxml2/include HINTS ${VISAGE_SEARCH_DIRS}) @@ -50,7 +51,7 @@ list(APPEND VISAGE_ARGS_LIST VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY) if (APPLE) - list(APPEND VISAGE_ARGS_LIST QuartzCore) + list(APPEND VISAGE_ARGS_LIST QuartzCore AppKit) endif () find_package_handle_standard_args(VISAGE DEFAULT_MSG ${VISAGE_ARGS_LIST}) @@ -59,7 +60,7 @@ set(VISAGE_INCLUDE_DIRS "${VISAGE_XML_INCLUDE_DIR}" "${VISAGE_OPENCV_INCLUDE_DIR set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY}" "${VISAGE_VISION_LIBRARY}" "${VISAGE_OPENCV_LIBRARY}") if (APPLE) - list(APPEND VISAGE_LIBRARIES ${QuartzCore}) + list(APPEND VISAGE_LIBRARIES ${QuartzCore} ${AppKit}) endif () mark_as_advanced(VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES) From b09cc55d6f91b0511858201f133b2f5475c741c9 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Fri, 8 Aug 2014 15:01:47 -0700 Subject: [PATCH 39/43] add QTKit to frameworks required for Visage --- cmake/modules/FindVisage.cmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindVisage.cmake b/cmake/modules/FindVisage.cmake index e2e66ec993..f14f15515a 100644 --- a/cmake/modules/FindVisage.cmake +++ b/cmake/modules/FindVisage.cmake @@ -34,6 +34,7 @@ if (APPLE) find_library(AppKit AppKit) find_library(QuartzCore QuartzCore) + find_library(QTKit QTKit) elseif (WIN32) find_path(VISAGE_XML_INCLUDE_DIR libxml/xmlreader.h PATH_SUFFIXES dependencies/libxml2/include HINTS ${VISAGE_SEARCH_DIRS}) find_path(VISAGE_OPENCV_INCLUDE_DIR opencv/cv.h PATH_SUFFIXES dependencies/OpenCV/include HINTS ${VISAGE_SEARCH_DIRS}) @@ -51,7 +52,7 @@ list(APPEND VISAGE_ARGS_LIST VISAGE_BASE_INCLUDE_DIR VISAGE_XML_INCLUDE_DIR VISAGE_CORE_LIBRARY VISAGE_VISION_LIBRARY VISAGE_OPENCV_LIBRARY) if (APPLE) - list(APPEND VISAGE_ARGS_LIST QuartzCore AppKit) + list(APPEND VISAGE_ARGS_LIST QuartzCore AppKit QTKit) endif () find_package_handle_standard_args(VISAGE DEFAULT_MSG ${VISAGE_ARGS_LIST}) @@ -60,7 +61,7 @@ set(VISAGE_INCLUDE_DIRS "${VISAGE_XML_INCLUDE_DIR}" "${VISAGE_OPENCV_INCLUDE_DIR set(VISAGE_LIBRARIES "${VISAGE_CORE_LIBRARY}" "${VISAGE_VISION_LIBRARY}" "${VISAGE_OPENCV_LIBRARY}") if (APPLE) - list(APPEND VISAGE_LIBRARIES ${QuartzCore} ${AppKit}) + list(APPEND VISAGE_LIBRARIES ${QuartzCore} ${AppKit} ${QTKit}) endif () mark_as_advanced(VISAGE_INCLUDE_DIRS VISAGE_LIBRARIES) From 481108ecd1f14db4d8dc71fc37a7021c64598493 Mon Sep 17 00:00:00 2001 From: Craig Hansen-Sturm Date: Sun, 10 Aug 2014 22:47:27 -0700 Subject: [PATCH 40/43] added support for biquad, parametric, and multi-band filter eq --- interface/src/Audio.cpp | 44 ++++- interface/src/Audio.h | 17 +- interface/src/Menu.cpp | 42 ++++ interface/src/Menu.h | 5 + libraries/audio/src/AudioFilter.cpp | 23 +++ libraries/audio/src/AudioFilter.h | 295 ++++++++++++++++++++++++++++ 6 files changed, 421 insertions(+), 5 deletions(-) create mode 100644 libraries/audio/src/AudioFilter.cpp create mode 100644 libraries/audio/src/AudioFilter.h diff --git a/interface/src/Audio.cpp b/interface/src/Audio.cpp index 2cba22b630..0484860c65 100644 --- a/interface/src/Audio.cpp +++ b/interface/src/Audio.cpp @@ -56,7 +56,6 @@ static const int MUTE_ICON_SIZE = 24; static const int RECEIVED_AUDIO_STREAM_CAPACITY_FRAMES = 100; - Audio::Audio(QObject* parent) : AbstractAudioInterface(parent), _audioInput(NULL), @@ -83,6 +82,7 @@ Audio::Audio(QObject* parent) : _noiseGateSampleCounter(0), _noiseGateOpen(false), _noiseGateEnabled(true), + _peqEnabled(false), _toneInjectionEnabled(false), _noiseGateFramesToClose(0), _totalInputAudioSamples(0), @@ -132,6 +132,7 @@ void Audio::init(QGLWidget *parent) { void Audio::reset() { _receivedAudioStream.reset(); resetStats(); + _peq.reset(); } void Audio::resetStats() { @@ -418,9 +419,15 @@ void Audio::start() { if (!outputFormatSupported) { qDebug() << "Unable to set up audio output because of a problem with output format."; } + + _peq.initialize( _inputFormat.sampleRate(), _audioInput->bufferSize() ); + } void Audio::stop() { + + _peq.finalize(); + // "switch" to invalid devices in order to shut down the state switchInputToAudioDevice(QAudioDeviceInfo()); switchOutputToAudioDevice(QAudioDeviceInfo()); @@ -462,7 +469,15 @@ void Audio::handleAudioInput() { int inputSamplesRequired = (int)((float)NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL * inputToNetworkInputRatio); QByteArray inputByteArray = _inputDevice->readAll(); - + + if (_peqEnabled && !_muted) { + // we wish to pre-filter our captured input, prior to loopback + + int16_t* ioBuffer = (int16_t*)inputByteArray.data(); + + _peq.render( ioBuffer, ioBuffer, inputByteArray.size() / sizeof(int16_t) ); + } + if (Menu::getInstance()->isOptionChecked(MenuOption::EchoLocalAudio) && !_muted && _audioOutput) { // if this person wants local loopback add that to the locally injected audio @@ -1172,6 +1187,31 @@ void Audio::renderToolBox(int x, int y, bool boxed) { glDisable(GL_TEXTURE_2D); } +void Audio::toggleAudioFilter() { + _peqEnabled = !_peqEnabled; +} + +void Audio::selectAudioFilterFlat() { + if (Menu::getInstance()->isOptionChecked(MenuOption::AudioFilterFlat)) { + _peq.loadProfile(0); + } +} +void Audio::selectAudioFilterTrebleCut() { + if (Menu::getInstance()->isOptionChecked(MenuOption::AudioFilterTrebleCut)) { + _peq.loadProfile(1); + } +} +void Audio::selectAudioFilterBassCut() { + if (Menu::getInstance()->isOptionChecked(MenuOption::AudioFilterBassCut)) { + _peq.loadProfile(2); + } +} +void Audio::selectAudioFilterSmiley() { + if (Menu::getInstance()->isOptionChecked(MenuOption::AudioFilterSmiley)) { + _peq.loadProfile(3); + } +} + void Audio::toggleScope() { _scopeEnabled = !_scopeEnabled; if (_scopeEnabled) { diff --git a/interface/src/Audio.h b/interface/src/Audio.h index 8fae6f3bdd..4fb54218af 100644 --- a/interface/src/Audio.h +++ b/interface/src/Audio.h @@ -19,6 +19,7 @@ #include "AudioStreamStats.h" #include "RingBufferHistory.h" #include "MovingMinMaxAvg.h" +#include "AudioFilter.h" #include #include @@ -125,7 +126,12 @@ public slots: void selectAudioScopeFiveFrames(); void selectAudioScopeTwentyFrames(); void selectAudioScopeFiftyFrames(); - + void toggleAudioFilter(); + void selectAudioFilterFlat(); + void selectAudioFilterTrebleCut(); + void selectAudioFilterBassCut(); + void selectAudioFilterSmiley(); + virtual void handleAudioByteArray(const QByteArray& audioByteArray); void sendDownstreamAudioStatsPacket(); @@ -252,12 +258,12 @@ private: // Audio scope methods for rendering void renderBackground(const float* color, int x, int y, int width, int height); void renderGrid(const float* color, int x, int y, int width, int height, int rows, int cols); - void renderLineStrip(const float* color, int x, int y, int n, int offset, const QByteArray* byteArray); + void renderLineStrip(const float* color, int x, int y, int n, int offset, const QByteArray* byteArray); // audio stats methods for rendering void renderAudioStreamStats(const AudioStreamStats& streamStats, int horizontalOffset, int& verticalOffset, float scale, float rotation, int font, const float* color, bool isDownstreamStats = false); - + // Audio scope data static const unsigned int NETWORK_SAMPLES_PER_FRAME = NETWORK_BUFFER_LENGTH_SAMPLES_PER_CHANNEL; static const unsigned int DEFAULT_FRAMES_PER_SCOPE = 5; @@ -270,6 +276,11 @@ private: int _scopeOutputOffset; int _framesPerScope; int _samplesPerScope; + + // Multi-band parametric EQ + bool _peqEnabled; + AudioFilterPEQ3 _peq; + QMutex _guard; QByteArray* _scopeInput; QByteArray* _scopeOutputLeft; diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 43d9fde01a..e6850aac6d 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -486,6 +486,48 @@ Menu::Menu() : true, appInstance->getAudio(), SLOT(toggleAudioNoiseReduction())); + + addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::AudioFilter, + 0, + false, + appInstance->getAudio(), + SLOT(toggleAudioFilter())); + + QMenu* audioFilterMenu = audioDebugMenu->addMenu("Audio Filter Options"); + addDisabledActionAndSeparator(audioFilterMenu, "Filter Response"); + { + QAction *flat = addCheckableActionToQMenuAndActionHash(audioFilterMenu, MenuOption::AudioFilterFlat, + 0, + true, + appInstance->getAudio(), + SLOT(selectAudioFilterFlat())); + + QAction *trebleCut = addCheckableActionToQMenuAndActionHash(audioFilterMenu, MenuOption::AudioFilterTrebleCut, + 0, + false, + appInstance->getAudio(), + SLOT(selectAudioFilterTrebleCut())); + + QAction *bassCut = addCheckableActionToQMenuAndActionHash(audioFilterMenu, MenuOption::AudioFilterBassCut, + 0, + false, + appInstance->getAudio(), + SLOT(selectAudioFilterBassCut())); + + QAction *smiley = addCheckableActionToQMenuAndActionHash(audioFilterMenu, MenuOption::AudioFilterSmiley, + 0, + false, + appInstance->getAudio(), + SLOT(selectAudioFilterSmiley())); + + + QActionGroup* audioFilterGroup = new QActionGroup(audioFilterMenu); + audioFilterGroup->addAction(flat); + audioFilterGroup->addAction(trebleCut); + audioFilterGroup->addAction(bassCut); + audioFilterGroup->addAction(smiley); + } + addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::EchoServerAudio); addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::EchoLocalAudio); addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::StereoAudio, 0, false, diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 3bef306bef..7ef744e62e 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -311,6 +311,11 @@ namespace MenuOption { const QString Animations = "Animations..."; const QString Atmosphere = "Atmosphere"; const QString Attachments = "Attachments..."; + const QString AudioFilter = "Audio Filter Bank"; + const QString AudioFilterFlat = "Flat Response"; + const QString AudioFilterTrebleCut= "Treble Cut"; + const QString AudioFilterBassCut = "Bass Cut"; + const QString AudioFilterSmiley = "Smiley Curve"; const QString AudioNoiseReduction = "Audio Noise Reduction"; const QString AudioScope = "Audio Scope"; const QString AudioScopeFiftyFrames = "Fifty"; diff --git a/libraries/audio/src/AudioFilter.cpp b/libraries/audio/src/AudioFilter.cpp new file mode 100644 index 0000000000..61e5e20171 --- /dev/null +++ b/libraries/audio/src/AudioFilter.cpp @@ -0,0 +1,23 @@ +// +// AudioFilter.cpp +// hifi +// +// Created by Craig Hansen-Sturm on 8/10/14. +// +// + +#include +#include +#include +#include "AudioRingBuffer.h" +#include "AudioFilter.h" + +template<> +AudioFilterPEQ3::FilterParameter AudioFilterPEQ3::_profiles[ AudioFilterPEQ3::_profileCount ][ AudioFilterPEQ3::_filterCount ] = { + + { { 300., 1., 1. }, { 1000., 1., 1. }, { 4000., 1., 1. } }, // flat response (default) + { { 300., 1., 1. }, { 1000., 1., 1. }, { 4000., .1, 1. } }, // treble cut + { { 300., .1, 1. }, { 1000., 1., 1. }, { 4000., 1., 1. } }, // bass cut + { { 300., 1.5, 0.71 }, { 1000., .5, 1. }, { 4000., 1.5, 0.71 } } // smiley curve +}; + diff --git a/libraries/audio/src/AudioFilter.h b/libraries/audio/src/AudioFilter.h new file mode 100644 index 0000000000..44dcd261d6 --- /dev/null +++ b/libraries/audio/src/AudioFilter.h @@ -0,0 +1,295 @@ +// +// AudioFilter.h +// hifi +// +// Created by Craig Hansen-Sturm on 8/9/14. +// +// + +#ifndef hifi_AudioFilter_h +#define hifi_AudioFilter_h + +//////////////////////////////////////////////////////////////////////////////////////////// +// Implements a standard biquad filter in "Direct Form 1" +// Reference http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt +// +class AudioBiquad { + + // + // private data + // + float _a0; // gain + float _a1; // feedforward 1 + float _a2; // feedforward 2 + float _b1; // feedback 1 + float _b2; // feedback 2 + + float _xm1; + float _xm2; + float _ym1; + float _ym2; + +public: + + // + // ctor/dtor + // + AudioBiquad() + : _xm1(0.) + , _xm2(0.) + , _ym1(0.) + , _ym2(0.) { + setParameters(0.,0.,0.,0.,0.); + } + + ~AudioBiquad() { + } + + // + // public interface + // + void setParameters( const float a0, const float a1, const float a2, const float b1, const float b2 ) { + _a0 = a0; _a1 = a1; _a2 = a2; _b1 = b1; _b2 = b2; + } + + void getParameters( float& a0, float& a1, float& a2, float& b1, float& b2 ) { + a0 = _a0; a1 = _a1; a2 = _a2; b1 = _b1; b2 = _b2; + } + + void render( const float* in, float* out, const int frames) { + + float x; + float y; + + for (int i = 0; i < frames; ++i) { + + x = *in++; + + // biquad + y = (_a0 * x) + + (_a1 * _xm1) + + (_a2 * _xm2) + - (_b1 * _ym1) + - (_b2 * _ym2); + + // update delay line + _xm2 = _xm1; + _xm1 = x; + _ym2 = _ym1; + _ym1 = y; + + *out++ = y; + } + } + + void reset() { + _xm1 = _xm2 = _ym1 = _ym2 = 0.; + } +}; + +//////////////////////////////////////////////////////////////////////////////////////////// +// Implements a single-band parametric EQ using a biquad "peaking EQ" configuration +// +// gain > 1.0 boosts the center frequency +// gain < 1.0 cuts the center frequency +// +class AudioParametricEQ { + + // + // private data + // + AudioBiquad _kernel; + float _sampleRate; + float _frequency; + float _gain; + float _slope; + + // helpers + void updateKernel() { + + /* + a0 = 1 + alpha*A + a1 = -2*cos(w0) + a2 = 1 - alpha*A + b1 = -2*cos(w0) + b2 = 1 - alpha/A + */ + + const float a = _gain; + const float omega = TWO_PI * _frequency / _sampleRate; + const float alpha = 0.5 * sinf(omega) / _slope; + const float gamma = 1.0 / ( 1.0 + (alpha/a) ); + + const float a0 = 1.0 + (alpha*a); + const float a1 = -2.0 * cosf(omega); + const float a2 = 1.0 - (alpha*a); + const float b1 = a1; + const float b2 = 1.0 - (alpha/a); + + _kernel.setParameters( a0*gamma,a1*gamma,a2*gamma,b1*gamma,b2*gamma ); + } + +public: + // + // ctor/dtor + // + AudioParametricEQ() { + + setParameters(0.,0.,0.,0.); + updateKernel(); + } + + ~AudioParametricEQ() { + } + + // + // public interface + // + void setParameters( const float sampleRate, const float frequency, const float gain, const float slope ) { + + _sampleRate = std::max(sampleRate,1.0f); + _frequency = std::max(frequency,2.0f); + _gain = std::max(gain,0.0f); + _slope = std::max(slope,0.00001f); + + updateKernel(); + } + + void getParameters( float& sampleRate, float& frequency, float& gain, float& slope ) { + sampleRate = _sampleRate; frequency = _frequency; gain = _gain; slope = _slope; + } + + void render(const float* in, float* out, const int frames ) { + _kernel.render(in,out,frames); + } + + void reset() { + _kernel.reset(); + } +}; + +//////////////////////////////////////////////////////////////////////////////////////////// +// Helper/convenience class that implements a bank of EQ objects +// +template< typename T, const int N> +class AudioFilterBank { + + // + // types + // + struct FilterParameter { + float _p1; + float _p2; + float _p3; + }; + + // + // private static data + // + static const int _filterCount = N; + static const int _profileCount = 4; + + static FilterParameter _profiles[_profileCount][_filterCount]; + + // + // private data + // + T _filters[ _filterCount ]; + float* _buffer; + float _sampleRate; + uint16_t _frameCount; + +public: + + // + // ctor/dtor + // + AudioFilterBank() + : _buffer(NULL) + , _sampleRate(0.) + , _frameCount(0) { + } + + ~AudioFilterBank() { + finalize(); + } + + // + // public interface + // + void initialize( const float sampleRate, const int frameCount ) { + finalize(); + + _buffer = (float*)malloc( frameCount * sizeof(float) ); + if(!_buffer) { + return; + } + + _sampleRate = sampleRate; + _frameCount = frameCount; + + reset(); + loadProfile(0); // load default profile "flat response" into the bank (see AudioFilter.cpp) + } + + void finalize() { + if (_buffer ) { + free (_buffer); + _buffer = NULL; + } + } + + void loadProfile( int profileIndex ) { + if (profileIndex >= 0 && profileIndex < _profileCount) { + + for (int i = 0; i < _filterCount; ++i) { + FilterParameter p = _profiles[profileIndex][i]; + + _filters[i].setParameters(_sampleRate,p._p1,p._p2,p._p3); + } + } + } + + void render( const float* in, float* out, const int frameCount ) { + for (int i = 0; i < _filterCount; ++i) { + _filters[i].render( in, out, frameCount ); + } + } + + void render( const int16_t* in, int16_t* out, const int frameCount ) { + if( !_buffer || ( frameCount > _frameCount ) ) + return; + + const int scale = (2 << ((8*sizeof(int16_t))-1)); + + // convert int16_t to float32 (normalized to -1. ... 1.) + for (int i = 0; i < frameCount; ++i) { + _buffer[i] = ((float)(*in++)) / scale; + } + // for this filter, we share input/output buffers at each stage, but our design does not mandate this + render( _buffer, _buffer, frameCount ); + + // convert float32 to int16_t + for (int i = 0; i < frameCount; ++i) { + *out++ = (int16_t)(_buffer[i] * scale); + } + } + + void reset() { + for (int i = 0; i < _filterCount; ++i ) { + _filters[i].reset(); + } + } + +}; + +//////////////////////////////////////////////////////////////////////////////////////////// +// Specializations of AudioFilterBank +// +typedef AudioFilterBank< AudioParametricEQ, 1> AudioFilterPEQ1; // bank with one band of PEQ +typedef AudioFilterBank< AudioParametricEQ, 2> AudioFilterPEQ2; // bank with two bands of PEQ +typedef AudioFilterBank< AudioParametricEQ, 3> AudioFilterPEQ3; // bank with three bands of PEQ +// etc.... + + +#endif // hifi_AudioFilter_h From 2469d958d6b750ed5ddf02780bb6f94aee815cf8 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 11 Aug 2014 09:57:13 -0700 Subject: [PATCH 41/43] include CoreFoundation for Audio.cpp defaultAudioDeviceForMode --- interface/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 82b102adf3..d705464479 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -172,10 +172,11 @@ add_definitions(-DQT_NO_BEARERMANAGEMENT) if (APPLE) # link in required OS X frameworks and include the right GL headers find_library(CoreAudio CoreAudio) + find_library(CoreFoundation CoreFoundation) find_library(GLUT GLUT) find_library(OpenGL OpenGL) - target_link_libraries(${TARGET_NAME} ${CoreAudio} ${GLUT} ${OpenGL}) + target_link_libraries(${TARGET_NAME} ${CoreFoundation} ${CoreAudio} ${GLUT} ${OpenGL}) # install command for OS X bundle INSTALL(TARGETS ${TARGET_NAME} From cadfaab770d894759f410862cd7f03f6c87a1ceb Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 11 Aug 2014 09:58:21 -0700 Subject: [PATCH 42/43] fix order now that I know my ABCs --- interface/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index d705464479..ce8400a413 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -176,7 +176,7 @@ if (APPLE) find_library(GLUT GLUT) find_library(OpenGL OpenGL) - target_link_libraries(${TARGET_NAME} ${CoreFoundation} ${CoreAudio} ${GLUT} ${OpenGL}) + target_link_libraries(${TARGET_NAME} ${CoreAudio} ${CoreFoundation} ${GLUT} ${OpenGL}) # install command for OS X bundle INSTALL(TARGETS ${TARGET_NAME} From 3d95f28fb9a1efbbed78087372f0c65eeb576f9f Mon Sep 17 00:00:00 2001 From: Craig Hansen-Sturm Date: Mon, 11 Aug 2014 11:51:49 -0700 Subject: [PATCH 43/43] added apache licensing/removed implicit double<->float conversions/addressed style guide issues --- libraries/audio/src/AudioFilter.cpp | 13 ++++++++----- libraries/audio/src/AudioFilter.h | 17 ++++++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/libraries/audio/src/AudioFilter.cpp b/libraries/audio/src/AudioFilter.cpp index 61e5e20171..28e7716578 100644 --- a/libraries/audio/src/AudioFilter.cpp +++ b/libraries/audio/src/AudioFilter.cpp @@ -3,7 +3,10 @@ // hifi // // Created by Craig Hansen-Sturm on 8/10/14. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #include @@ -15,9 +18,9 @@ template<> AudioFilterPEQ3::FilterParameter AudioFilterPEQ3::_profiles[ AudioFilterPEQ3::_profileCount ][ AudioFilterPEQ3::_filterCount ] = { - { { 300., 1., 1. }, { 1000., 1., 1. }, { 4000., 1., 1. } }, // flat response (default) - { { 300., 1., 1. }, { 1000., 1., 1. }, { 4000., .1, 1. } }, // treble cut - { { 300., .1, 1. }, { 1000., 1., 1. }, { 4000., 1., 1. } }, // bass cut - { { 300., 1.5, 0.71 }, { 1000., .5, 1. }, { 4000., 1.5, 0.71 } } // smiley curve + // Freq Gain Q Freq Gain Q Freq Gain Q + { { 300.0f, 1.0f, 1.0f }, { 1000.0f, 1.0f, 1.0f }, { 4000.0f, 1.0f, 1.0f } }, // flat response (default) + { { 300.0f, 1.0f, 1.0f }, { 1000.0f, 1.0f, 1.0f }, { 4000.0f, 0.1f, 1.0f } }, // treble cut + { { 300.0f, 0.1f, 1.0f }, { 1000.0f, 1.0f, 1.0f }, { 4000.0f, 1.0f, 1.0f } }, // bass cut + { { 300.0f, 1.5f, 0.71f }, { 1000.0f, 0.5f, 1.0f }, { 4000.0f, 1.50f, 0.71f } } // smiley curve }; - diff --git a/libraries/audio/src/AudioFilter.h b/libraries/audio/src/AudioFilter.h index 44dcd261d6..0f3ec06f64 100644 --- a/libraries/audio/src/AudioFilter.h +++ b/libraries/audio/src/AudioFilter.h @@ -3,7 +3,10 @@ // hifi // // Created by Craig Hansen-Sturm on 8/9/14. +// Copyright 2014 High Fidelity, Inc. // +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // #ifndef hifi_AudioFilter_h @@ -117,14 +120,14 @@ class AudioParametricEQ { const float a = _gain; const float omega = TWO_PI * _frequency / _sampleRate; - const float alpha = 0.5 * sinf(omega) / _slope; - const float gamma = 1.0 / ( 1.0 + (alpha/a) ); + const float alpha = 0.5f * sinf(omega) / _slope; + const float gamma = 1.0f / ( 1.0f + (alpha/a) ); - const float a0 = 1.0 + (alpha*a); - const float a1 = -2.0 * cosf(omega); - const float a2 = 1.0 - (alpha*a); + const float a0 = 1.0f + (alpha*a); + const float a1 = -2.0f * cosf(omega); + const float a2 = 1.0f - (alpha*a); const float b1 = a1; - const float b2 = 1.0 - (alpha/a); + const float b2 = 1.0f - (alpha/a); _kernel.setParameters( a0*gamma,a1*gamma,a2*gamma,b1*gamma,b2*gamma ); } @@ -257,7 +260,7 @@ public: } void render( const int16_t* in, int16_t* out, const int frameCount ) { - if( !_buffer || ( frameCount > _frameCount ) ) + if (!_buffer || ( frameCount > _frameCount )) return; const int scale = (2 << ((8*sizeof(int16_t))-1));