Skip to content

Commit

Permalink
detect and use system libgit2 with pkg-config
Browse files Browse the repository at this point in the history
  • Loading branch information
cjmayo committed Jul 3, 2016
1 parent 4d55a72 commit 1923458
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 45 deletions.
53 changes: 8 additions & 45 deletions phoenix.pro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# /*******************************************************************
#
# Part of the Fritzing project - http://fritzing.org
# Copyright (c) 2007-08 Fritzing
# Copyright (c) 2007-16 Fritzing
#
# Fritzing is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -32,6 +32,10 @@

CONFIG += debug_and_release

unix:!macx {
CONFIG += link_pkgconfig
}

win32 {
# release build using msvc 2010 needs to use Multi-threaded (/MT) for the code generation/runtime library option
# release build using msvc 2010 needs to add msvcrt.lib;%(IgnoreSpecificDefaultLibraries) to the linker/no default libraries option
Expand Down Expand Up @@ -164,53 +168,12 @@ RC_FILE = fritzing.rc
RESOURCES += phoenixresources.qrc

# Fritzing is using libgit2 since version 0.9.3

LIBGIT2INCLUDE = ../libgit2/include
exists($$LIBGIT2INCLUDE/git2.h) {
message("found libgit2 include path at $$LIBGIT2INCLUDE")
packagesExist(libgit2) {
PKGCONFIG += libgit2
} else {
message("Fritzing requires libgit2")
message("Build it from the repo at https://github.com/libgit2")
message("See https://github.com/fritzing/fritzing-app/wiki for details.")

error("libgit2 include path not found in $$LIBGIT2INCLUDE")
}

INCLUDEPATH += $$LIBGIT2INCLUDE

win32 {
contains(QMAKE_TARGET.arch, x86_64) {
LIBGIT2LIB = ../libgit2/build64
} else {
LIBGIT2LIB = ../libgit2/build32
}

exists($$LIBGIT2LIB/git2.lib) {
message("found libgit2 library in $$LIBGIT2LIB")
} else {
error("libgit2 library not found in $$LIBGIT2LIB")
}
}

unix {
LIBGIT2LIB = ../libgit2/build
macx {
exists($$LIBGIT2LIB/libgit2.dylib) {
message("found libgit2 library in $$LIBGIT2LIB")
} else {
error("libgit2 library not found in $$LIBGIT2LIB")
}
} else {
exists($$LIBGIT2LIB/libgit2.so) {
message("found libgit2 library in $$LIBGIT2LIB")
} else {
error("libgit2 library not found in $$LIBGIT2LIB")
}
}
include(pri/libgit2detect.pri)
}

LIBS += -L$$LIBGIT2LIB -lgit2

include(pri/kitchensink.pri)
include(pri/mainwindow.pri)
include(pri/partsbinpalette.pri)
Expand Down
60 changes: 60 additions & 0 deletions pri/libgit2detect.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# /*******************************************************************
# Part of the Fritzing project - http://fritzing.org
# Copyright (c) 2016 Fritzing
# Fritzing is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# Fritzing 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 General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with Fritzing. If not, see <http://www.gnu.org/licenses/>.
# ********************************************************************

LIBGIT2INCLUDE = ../libgit2/include
exists($$LIBGIT2INCLUDE/git2.h) {
message("found libgit2 include path at $$LIBGIT2INCLUDE")
} else {
message("Fritzing requires libgit2")
message("Build it from the repo at https://github.com/libgit2")
message("See https://github.com/fritzing/fritzing-app/wiki for details.")

error("libgit2 include path not found in $$LIBGIT2INCLUDE")
}

INCLUDEPATH += $$LIBGIT2INCLUDE

win32 {
contains(QMAKE_TARGET.arch, x86_64) {
LIBGIT2LIB = ../libgit2/build64
} else {
LIBGIT2LIB = ../libgit2/build32
}

exists($$LIBGIT2LIB/git2.lib) {
message("found libgit2 library in $$LIBGIT2LIB")
} else {
error("libgit2 library not found in $$LIBGIT2LIB")
}
}

unix {
LIBGIT2LIB = ../libgit2/build
macx {
exists($$LIBGIT2LIB/libgit2.dylib) {
message("found libgit2 library in $$LIBGIT2LIB")
} else {
error("libgit2 library not found in $$LIBGIT2LIB")
}
} else {
exists($$LIBGIT2LIB/libgit2.so) {
message("found libgit2 library in $$LIBGIT2LIB")
} else {
error("libgit2 library not found in $$LIBGIT2LIB")
}
}
}

LIBS += -L$$LIBGIT2LIB -lgit2

0 comments on commit 1923458

Please sign in to comment.