Code Monkey home page Code Monkey logo

crossguid's Introduction

CrossGuid Build Status

CrossGuid is a minimal, cross platform, C++ GUID library. It uses the best native GUID/UUID generator on the given platform and has a generic class for parsing, stringifying, and comparing IDs. The guid generation technique is determined by your platform:

Linux

On linux you can use libuuid which is pretty standard. On distros like Ubuntu it is available by default but to use it you need the header files so you have to do:

sudo apt-get install uuid-dev

Mac/iOS

On Mac or iOS you can use CFUUIDCreate from CoreFoundation. Since it's a plain C function you don't even need to compile as Objective-C++.

Windows

On Windows we just use the the built-in function CoCreateGuid. CMake can generate a Visual Studio project if that's your thing.

Android

The Android version uses a handle to a JNIEnv object to invoke the randomUUID() function on java.util.UUID from C++. The Android specific code is all in the android/ subdirectory. If you have an emulator already running, then you can run the android.sh script in the root directory. It has the following requirements:

  • Android emulator is already running (or you have physical device connected).
  • You're using bash.
  • adb is in your path.
  • You have an Android sdk setup including ANDROID_HOME environment variable.

Versions

This is version 0.2 of CrossGuid. If you all already using CrossGuid and your code uses GuidGenerator then you are using version 0.1. Differences in version 0.2:

  • Put everything inside the namespace xg instead of using the global namespace.
  • Removed GuidGenerator class and replaced with the free function xg::newGuid. This is the way I originally wanted it to work but since Android is a special snowflake requiring state (JNIEnv *) I introduced the GuidGenerator class specifically so that there would be somewhere to store the JNIEnv * when running on Android. However, this basically meant complicating the library for the sake of one platform. In version 0.2 the goal is to design for the normal platforms and let Android be weird. In Android you just need to run xg::initJni(JNIEnv *) before you create any guids. The JNIEnv * is just stored as a global variable.
  • Added CMake build system. Instead of different scripts for each platform you can just run cmake and it should handle each platform (except Android which again is special).
  • Actual guid bytes are stored in std::array<unsigned char, 16> instead of std::vector<unsigned char>.
  • More error checking (like if you try to create a guid with invalid number of bytes).

If you're happily using version 0.1 then there's not really any reason to change.

Compiling

Just do the normal cmake thing:

mkdir build
cd build
cmake ..
make install

Running tests

After compiling as described above you should get two files: libcrossguid.a (the static library) and crossguid-test (the test runner). So to run the tests just do:

./crossguid-test

Basic usage

Creating guids

Create a new random guid:

#include <crossguid/guid.hpp>
...
auto g = xg::newGuid();

NOTE: On Android you need to call xg::initJni(JNIEnv *) first so that it is possible for xg::newGuid() to call back into java libraries. initJni only needs to be called once when the process starts.

Create a new zero guid:

xg::Guid g;

Create from a string:

xg::Guid g("c405c66c-ccbb-4ffd-9b62-c286c0fd7a3b");

Checking validity

If you have some string value and you need to check whether it is a valid guid then you can simply attempt to construct the guid:

xg::Guid g("bad-guid-string");
if (!g.isValid())
{
	// do stuff
}

If the guid string is not valid then all bytes are set to zero and isValid() returns false.

Converting guid to string

First of all, there is normally no reason to convert a guid to a string except for in debugging or when serializing for API calls or whatever. You should definitely avoid storing guids as strings or using strings for any computations. If you do need to convert a guid to a string, then you can utilize strings because the << operator is overloaded. To print a guid to std::cout:

void doGuidStuff()
{
    auto myGuid = xg::newGuid();
    std::cout << "Here is a guid: " << myGuid << std::endl;
}

Or to store a guid in a std::string:

void doGuidStuff()
{
    auto myGuid = xg::newGuid();
    std::stringstream stream;
    stream << myGuid;
    auto guidString = stream.str();
}

There is also a str() function that returns a std::string:

std::string guidStr = xg::newGuid().str();

Creating a guid from raw bytes

It's unlikely that you will need this, but this is done within the library internally to construct a Guid object from the raw data given by the system's built-in guid generation function. There are two key constructors for this:

Guid(std::array<unsigned char, 16> &bytes);

and

Guid(const unsigned char * bytes);

When possible prefer the std::array constructor because it is safer. If you pass in an incorrectly sized C array then bad things will happen.

Comparing guids

== and != are implemented, so the following works as expected:

void doGuidStuff()
{
    auto guid1 = xg::newGuid();
    auto guid2 = xg::newGuid();

    auto guidsAreEqual = guid1 == guid2;
    auto guidsAreNotEqual = guid1 != guid2;
}

Hashing guids

Guids can be used directly in containers requireing std::hash such as std::map,std::unordered_map` etc.

License

The MIT License (MIT)

Copyright (c) 2014 Graeme Hill (http://graemehill.ca)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

crossguid's People

Contributors

asmaloney avatar eliaskosunen avatar fish2000 avatar gabyx avatar graeme-hill avatar hb3p8 avatar montellese avatar nabijaczleweli avatar olafhering avatar spuddles avatar sukhmel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

crossguid's Issues

Makefile does not match source

The source package for v0.2.1 contains Guid.cpp and Guid.hpp.

  • The Makefile expects guid.cpp and guid.h.
  • Internally, Guid.cpp expects Guid.hpp.

This breaks the build (doubly so on case-sensitive filesystems).

Now require C++17?

Commit d9e6cd1 added std::string_view which was introduced in C++17.

Did you intend to require C++17 from now on? (FWIW I am using crossguid with C++11.)

Thanks!

No CMake install target when Crossguid is not the root project

Hi @graeme-hill

When using CMake, no INSTALL target is created if crossguid is not the root project.
We're in this situation because we use crossguid as a submodule of a parent CMake project (however we still need the INSTALL target).

This seems to be due to this line:

if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})

Why is that condition required?
I've seen other projects adding an option to toggle installation on or off (eg. "CROSSGUID_INSTALL_ENABLED").
I could propose a PR with something similar if that's ok for you.

Create new release

Could you create a new release? There have been quite a lot of updates and especially the introduction of the pkgconfig file is interesting for projects who would like to depend on this library.

Help documentation problem on the cmake command

README.me says to invoke cmake like this:

cmake .. -DCMAKE_INSTALL_PREFIX="/usr/local/include"

Doing so results in an installation underneath this directory. That is, these directories are created:

/usr/local/include/lib
/usr/local/include/include
/usr/local/include/include/crossguid

That cmake command should probably exclude the /include part at the end. This was on a Mac. I presume it's a similar issue on other platforms.

[Android] Continuous usage causes local references leak and app crash

Hi! Thanks for the great library.
We use your library in our project and faced with an issue. We start new thread in native code and perform operations including generating of multiple uuids. After some time the application crashes with native stacktrace like following:

art/runtime/indirect_reference_table.cc:115] JNI ERROR (app bug): local reference table overflow (max=512)
art/runtime/indirect_reference_table.cc:115] local reference table dump:
art/runtime/indirect_reference_table.cc:115]   Last 10 entries (of 512):
...
art/runtime/indirect_reference_table.cc:115]       508: 0x12d94490 java.util.UUID
...
art/runtime/indirect_reference_table.cc:115]       505: 0x12c05f30 java.util.UUID
...
art/runtime/indirect_reference_table.cc:115]       502: 0x12c05ec8 java.util.UUID
art/runtime/indirect_reference_table.cc:115]   Summary:
...
art/runtime/indirect_reference_table.cc:115]       181 of java.util.UUID (181 unique instances)

It seems that jobject javaUuid local reference in Guid newGuid(), returned from randomUUID() java method should be deleted after bits evaluation.

Also, as far as newGuid() is callable from different threads after initJni() AndroidGuidInfo.uuidClass must be a global reference to prevent illegal usage and crash.

Is it suitable to open PR with implementation of this behaviour?

README should indicate C++17 is required

I don't understand the rationale for making this useful library require C++17 but, since it does, it should be indicated in the README so it doesn't surprise people.

CoCreateGuid is not implemented?

linker: C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.29.30133/bin/HostX64/x64/link.exe
error LNK2019: unresolved external symbol __imp_CoCreateGuid referenced in function "class xg::Guid __cdecl xg::newGuid(void)"

Utilitze JS crypto.createUUID() when compiling with Emscripten

Similar to the other platform defines, emscripten provides a mechanism for calling JS APIs from C++ and all modern browsers provide a secure UUID generation method.

I'm current experimenting with this for a cross platform I'm building, one of which is to WASM but I am not a cmake wizard and am just statically including all the necessary crossguid files in my app with crossguid as a submodule. I can get all the includes and everything straightened out but am not sure of the proper way to nest the crossguid build from another cmake project.

Using -Werror on OSX causes compilation error

Please see the following log, https://travis-ci.org/inexorgame/entity-system/jobs/502307832#L1700

This is caused by -Wunused and should not cause a linker error. The idiomatic C++17 way to solve this is using maybe_unused.

Currently

set(WARNINGS "-Werror" "-Wall")
prevents us from building crossguid (commit b151b7d) as mentioned in #47

A suggested quick fix is disabling -Werror (which isn't amazing anyways, see this post), but we would hope to be able to switch back to crossguid/master as soon as possible, with unused functions being marked as such.

add a build system of some sort

rather than various little wrapper scripts (that don't use the proper compiler or build settings), can we get a Makefile or something ? then we can do like make linux and make test and make install.

Link to libuuid statically on Linux?

Is there an easy way to get crossguid to link to libuuid statically on Linux?

I'm a perpetual cmake novice, but I'm guessing I'd need to add an option(CROSSGUID_LINK_LIBUUID_STATIC ...) and then modify FindLibuuid.cmake?

[Android] impossible to use newGuid() between jni calls

Hi! Thank you for the great library again.
I faced the issue that newGuid() could not be called between separate jni calls or from different threads. It seems, AndroidGuidInfo.uuidClass must be global reference to allow such calls. Also, JniEnv * variable should be passed from the current context into newGuid() to operate with jni functions to prevent context mismatch.
Is it appropriate to me to open PR with implementation of this behaviour?

std::hash<Guid> implementation for use with std containers

Here's a little piece of code that can be added to be able to use Guid as key for containers like std::unordered_map:

namespace std
{
template<>
struct hash<Guid>
{
    size_t operator()(const Guid &guid) const
    {
        stringstream ss;
        ss << guid;
        return hash<string>()(ss.str());
    }
};
}

New release?

Dear all,
it looks like the last release is now some time ago. Would it be possible to do another release, so I can have a stable, up-to-date environment please? That would make it easier for the project to be used by other's as well.

Thanks!

Fix constructor std::array error on CLang 9.0.0

On Clang (9.0.0) the following error is reported:
error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
Guid::Guid() : _bytes{ 0 }
^
{}
/Users/dk8mohos/Projects/LPFPlatform/3rdParty/crossguid/Guid.cpp:290:3: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
bytes.byte0,
^~~~~~~~~~~~
2 errors generated.

A quick fix would be adding "-Wno-missing-braces" to the compiler flags (APPLE).

CMAKE warning on VS2022 and possible compatible fork

I know the library is effectively unmaintained, in the interest of keeping a compatible fork, is there currently anyone that hard requires a CMAKE version below 3.15?

There is a cmake warning on windows using VS2022 cl : Command line warning D9025 : overriding '/W3' with '/W4' which would be fixed by bumping cmake_minimum_required up to 3.15 or above, see discussiong here. Is there currently any blocker to this?

How set up preprocessor definitions.

Hello mr Graeme Hill. Thank you for good library. It will be good to point in readme how set preprocessors flags in some ide like visual studio 2012 -> project properties->Configuration properties-> C/C++ -> Preprocessor -> Preprocessor Definitions (type you platform defenition(GUID_LIBUUID, GUID_CFUUID, GUID_WINDOWS, GUID_ANDROID ) ). Best regards.

Symbols are not exported when built with LTO

When built using LTO:
CFLAGS="${CFLAGS} -flto"
CXXFLAGS="${CXXFLAGS} -flto"
LDFLAGS="${LDFLAGS} -flto"

no symbols are exported:
$ readelf -sW /usr/lib64/libcrossguid.a | c++filt | grep Guid::Guid
returns nothing.

Building error on Windows(Msys2)

[1/5] Building CXX object CMakeFiles/crossguid-test.dir/test/TestMain.cpp.obj
FAILED: CMakeFiles/crossguid-test.dir/test/TestMain.cpp.obj
E:\msys64\mingw64\bin\c++.exe  -IE:/msys64/home/test/crossguid-master/include -O3 -DNDEBUG -std=c++17 -MD -MT CMakeFiles/crossguid-test.dir/test/TestMain.cpp.obj -MF CMakeFiles\crossguid-test.dir\test\TestMain.cpp.obj.d -o CMakeFiles/crossguid-test.dir/test/TestMain.cpp.obj -c E:/msys64/home/test/crossguid-master/test/TestMain.cpp
In file included from E:/msys64/home/test/crossguid-master/test/Test.hpp:3,
                 from E:/msys64/home/test/crossguid-master/test/TestMain.cpp:1:
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp: In member function 'std::size_t std::hash<xg::Guid>::operator()(const xg::Guid&) const':
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:145:31: error: 'uint64_t' does not name a type
  145 |                         const uint64_t* p = reinterpret_cast<const uint64_t*>(guid.bytes().data());
      |                               ^~~~~~~~
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:39:1: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
   38 | #include <iomanip>
  +++ |+#include <cstdint>
   39 |
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:146:50: error: 'uint64_t' was not declared in this scope
  146 |                         return xg::details::hash<uint64_t, uint64_t>{}(p[0], p[1]);
      |                                                  ^~~~~~~~
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:146:50: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:146:68: error: template argument 1 is invalid
  146 |                         return xg::details::hash<uint64_t, uint64_t>{}(p[0], p[1]);
      |                                                                    ^
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:146:72: error: 'p' was not declared in this scope
  146 |                         return xg::details::hash<uint64_t, uint64_t>{}(p[0], p[1]);
      |                                                                        ^
[2/5] Building CXX object CMakeFiles/crossguid-test.dir/test/Test.cpp.obj
FAILED: CMakeFiles/crossguid-test.dir/test/Test.cpp.obj
E:\msys64\mingw64\bin\c++.exe  -IE:/msys64/home/test/crossguid-master/include -O3 -DNDEBUG -std=c++17 -MD -MT CMakeFiles/crossguid-test.dir/test/Test.cpp.obj -MF CMakeFiles\crossguid-test.dir\test\Test.cpp.obj.d -o CMakeFiles/crossguid-test.dir/test/Test.cpp.obj -c E:/msys64/home/test/crossguid-master/test/Test.cpp
In file included from E:/msys64/home/test/crossguid-master/test/Test.hpp:3,
                 from E:/msys64/home/test/crossguid-master/test/Test.cpp:1:
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp: In member function 'std::size_t std::hash<xg::Guid>::operator()(const xg::Guid&) const':
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:145:31: error: 'uint64_t' does not name a type
  145 |                         const uint64_t* p = reinterpret_cast<const uint64_t*>(guid.bytes().data());
      |                               ^~~~~~~~
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:39:1: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
   38 | #include <iomanip>
  +++ |+#include <cstdint>
   39 |
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:146:50: error: 'uint64_t' was not declared in this scope
  146 |                         return xg::details::hash<uint64_t, uint64_t>{}(p[0], p[1]);
      |                                                  ^~~~~~~~
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:146:50: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:146:68: error: template argument 1 is invalid
  146 |                         return xg::details::hash<uint64_t, uint64_t>{}(p[0], p[1]);
      |                                                                    ^
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:146:72: error: 'p' was not declared in this scope
  146 |                         return xg::details::hash<uint64_t, uint64_t>{}(p[0], p[1]);
      |                                                                        ^
FAILED: CMakeFiles/crossguid.dir/src/guid.cpp.obj
-Werror -Wall -MD -MT CMakeFiles/crossguid.dir/src/guid.cpp.obj -MF CMakeFiles\crossguid.dir\src\guid.cpp.obj.d -o CMakeFiles/crossguid.dir/src/guid.cpp.obj -c E:/msys64/home/test/crossguid-master/src/guid.cpp
In file included from E:/msys64/home/test/crossguid-master/src/guid.cpp:26:
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp: In member function 'std::size_t std::hash<xg::Guid>::operator()(const xg::Guid&) const':
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:145:31: error: 'uint64_t' does not name a type
  145 |                         const uint64_t* p = reinterpret_cast<const uint64_t*>(guid.bytes().data());
      |                               ^~~~~~~~
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:39:1: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
   38 | #include <iomanip>
  +++ |+#include <cstdint>
   39 |
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:146:50: error: 'uint64_t' was not declared in this scope
  146 |                         return xg::details::hash<uint64_t, uint64_t>{}(p[0], p[1]);
      |                                                  ^~~~~~~~
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:146:50: note: 'uint64_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'?
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:146:68: error: template argument 1 is invalid
  146 |                         return xg::details::hash<uint64_t, uint64_t>{}(p[0], p[1]);
      |                                                                    ^
E:/msys64/home/test/crossguid-master/include/crossguid/guid.hpp:146:72: error: 'p' was not declared in this scope
  146 |                         return xg::details::hash<uint64_t, uint64_t>{}(p[0], p[1]);
      |                                                                        ^
ninja: build stopped: subcommand failed.

After adding #include <cstdint>, everything works well!

Fork of crossguid

With many of the issues here being unaddressed, and @graeme-hill being rather unresponsive, I though I'd release my previously private fork to the public to use. You can find it here: https://github.com/eliaskosunen/crossguid.

Its interface is not backwards-compatible (see README for changes and usage), and it lacks Android support, but it has the added advantage of, among other things, supporting C++11, and being alive with an active maintainer (me!).

Go take a look and give it a try, if you want to.

Warnings as errors makes build fail (CMake)

guid.cpp row 244:

// set all bytes to zero
void Guid::zeroify()
{
	std::fill(_bytes.begin(), _bytes.end(), 0);
}

should be:

// set all bytes to zero
void Guid::zeroify()
{
	std::fill(_bytes.begin(), _bytes.end(), static_cast<unsigned char>(0));
}

so that /WX option on windows doesn't make the build fail.

Details on Mainteinance / Help ?

Hi @graeme-hill,

First of all, thank you for the library. Really appreciating.

I would like to ask two questions regarding maintenance:

Time

In issue #52 I read

I still maintain this but not closely.

Would it be possible to have a more precise view on the aspects that define "closely" in the current moment ?

For example, in the scenario where none of us has, of course, the time to do everything that is needed for all subjects, which is aspect that for you is the hardest for allocate time for ?

ex.

  • time to read, analyze, and process issues [y/n]
  • time to inspect, analyze, review, and test PRs [y/n]
  • time to adapt to the advancement of build tools [y/n]
  • time to enhance the library [y/n]
  • time for strategic decision-making [y/n]

As @jean has mentioned on some issues, there might be some staling PRs work since a while, one of the blocking.

Help

How could the community help the library ?

a) finding co-maintainers that share the whole work
b) finding co-maintainers that will perform some of the tasks above for you, and you will still direct, steer, and approve
c) choosing a drop-in fork, and making it official on the Readme
d) other ?

Thank you in advance, and wishing a great week-end

Android is hard to integrate

I am new to Android development and we are doing a cross platform game. I find your instructions to be confusing and it seems much more bloated than other platform integrations. Why don't you simply make a simple implementation and read a string from "/proc/sys/kernel/random/uuid" to avoid all the java integration?

Guid bytearray access

Hi,

First, I would like to thank you maintaining this project. It is a very useful piece of code.

My use case needs to transmit the GUID through a network layer. As GUID are stored on 16 bytes, I would like to transmit those bytes directly through the network.
Currently, I'm converting the GUID to a string on the server side, and then converting the string back to GUID on the client side. This conversion eats few CPU cycles, and also takes much more space to transmit.

Do you mind adding an accessor to the std::array ?

Thank you in advance,
All the best

Handle leak on Android

I believe this should be added to Android code in the end of function GuidGenerator::newGuid()

_env->DeleteLocalRef(javaUuid);

.. otherwise it will overload the handle count on heavy use.

CMake fails when attempting to build 32 bit version

I'm building a project that's 32 bit only and despite having uuid-dev:i386 installed, the CMake generation fails.

Project Dockerfile: https://github.com/Southclaws/pawn-uuid/blob/master/Dockerfile

-- Could NOT find LibUUID (missing: LIBUUID_LIBRARY)
CMake Error at lib/crossguid/CMakeLists.txt:50 (message):
  You might need to run 'sudo apt-get install uuid-dev' or similar

I'm no CMake expert either so I might have missed something simple like an option or flag here.

Make CMake install directives optional

Libraries should always have the CMake install directives optional, as they always are used within larger projects. Like so:

if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
    ... move install directives within this if scope ...
endif()

Want shared and static builds

Need support for shared builds, changing following line in CMakeLists.txt

add_library(crossguid STATIC ${CMAKE_CURRENT_SOURCE_DIR}/src/guid.cpp)

to

add_library(crossguid ${CMAKE_CURRENT_SOURCE_DIR}/src/guid.cpp)

will still default to STATIC build and when needed for shared build we can just run cmake as

cmake -DBUILD_SHARED_LIBS=ON ..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.