Minor CMakeLists.txt cleanup

First of all, specify the build directory as an include directory.
This enables us to build out of source, for example:
    mkdir build
    cd build
    cmake ..

Remove all the if(WIN32) clauses, and use an option to specify wheter we
want to link to the static versions of libsigrok*. That's basically what
the WIN32 clauses were doing anyway. This makes the "what is going on"
more readeable.
On WIN32, automatically set this option to link to the static libraries.

Add a copyright header to CMakeLists.txt

Signed-off-by: Alexandru Gagniuc <[email protected]>
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7e1768e..afbe0df 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,27 +1,7 @@
-##
-## This file is part of pulseview
-##
-## Copyright (C) 2012 Alexandru Gagniuc <[email protected]>
-##
-## This program 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 2 of the License, or
-## (at your option) any later version.
-## 
-## This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
-##
-
 cmake_minimum_required(VERSION 2.6)
 include(FindPkgConfig)
 
 project(pulseview)
-set(VERSION 0.1.0)
 
 find_package(PkgConfig)
 pkg_check_modules(PKGDEPS REQUIRED
@@ -31,13 +11,14 @@ pkg_check_modules(PKGDEPS REQUIRED
 
 # On Windows/MinGW we explicitly point cmake to the Boost directory.
 if(WIN32)
-	# FIXME: Is BOOST always packaged in /usr/local on win32 ?
-	set(BOOST_ROOT /usr/local)
-endif()
+set(BOOST_ROOT /usr/local)
+endif(WIN32)
 
 find_package(Qt4 REQUIRED)
 find_package(Boost 1.46 COMPONENTS unit_test_framework REQUIRED)
 
+set(VERSION 0.1.0)
+
 set(pulseview_SOURCES
 	about.cpp
 	datasnapshot.cpp
@@ -88,69 +69,79 @@ qt4_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES})
 
 include(${QT_USE_FILE})
 
-################################################################################
-## Global defines
-################################################################################
 add_definitions(${QT_DEFINITIONS})
 add_definitions(-DAPP_VERSION="${VERSION}")
-# TODO: Explain the reason for this define
-add_definitions(-DBOOST_TEST_DYN_LINK)
-
-################################################################################
-## Global include directories
-################################################################################
-include_directories(${Boost_INCLUDE_DIRS})
-# We generate a few files, so we also need to look in the build directory when
-# building out of tree
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
 
-################################################################################
-## Link libraries configuration
-################################################################################
-link_directories(${Boost_LIBRARY_DIRS})
-
-set(PULSEVIEW_LINK_LIBS
-	${Boost_LIBRARIES}
-	${QT_LIBRARIES}
+# On Windows/MinGW we need PKGDEPS_STATIC_INCLUDE_DIRS.
+if(WIN32)
+include_directories(
+	${include_directories}
+	${Boost_INCLUDE_DIRS}
+	${PKGDEPS_STATIC_INCLUDE_DIRS}
 )
+else(WIN32)
+include_directories(
+	${include_directories}
+	${Boost_INCLUDE_DIRS}
+	${PKGDEPS_INCLUDE_DIRS}
+)
+endif(WIN32)
 
-option(STATIC_PKGDEPS_LIBS "Statically link to sigrok libraries" OFF)
+# On Windows/MinGW we need PKGDEPS_STATIC_LIBRARY_DIRS.
 if(WIN32)
-	# On Windows/MinGW we need to statically link to libraries
-	# This option is user configurable, but enable it by default on win32
-	set(STATIC_PKGDEPS_LIBS ON)
-endif()
-
-if(STATIC_PKGDEPS_LIBS)
-	include_directories(${PKGDEPS_STATIC_INCLUDE_DIRS})
-	link_directories(${PKGDEPS_STATIC_LIBRARY_DIRS})
-	list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_STATIC_LIBRARIES})
-else()
-	include_directories(${PKGDEPS_INCLUDE_DIRS})
-	link_directories(${PKGDEPS_LIBRARY_DIRS})
-	list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES})
-endif()
-
-################################################################################
-## Back to our pulseview binaries
-################################################################################
+link_directories(
+	${Boost_LIBRARY_DIRS}
+	${PKGDEPS_STATIC_LIBRARY_DIRS}
+)
+else(WIN32)
+link_directories(
+	${Boost_LIBRARY_DIRS}
+	${PKGDEPS_LIBRARY_DIRS}
+)
+endif(WIN32)
+
 add_executable(pulseview
 	${pulseview_SOURCES}
 	${pulseview_HEADERS_MOC}
 	${pulseview_FORMS_HEADERS}
 	${pulseview_RESOURCES_RCC}
 )
+
+# On Windows/MinGW we need PKGDEPS_STATIC_LIBRARIES.
+if(WIN32)
+target_link_libraries(pulseview
+	${Boost_LIBRARIES}
+	${PKGDEPS_STATIC_LIBRARIES}
+	${QT_LIBRARIES}
+)
+else(WIN32)
 target_link_libraries(pulseview
-	${PULSEVIEW_LINK_LIBS}
+	${Boost_LIBRARIES}
+	${PKGDEPS_LIBRARIES}
+	${QT_LIBRARIES}
 )
+endif(WIN32)
+
+add_definitions(-DBOOST_TEST_DYN_LINK)
 
 add_executable(pulseview-test
 	${pulseview_TEST_SOURCES}
 )
+
+# On Windows/MinGW we need PKGDEPS_STATIC_LIBRARIES.
+if(WIN32)
+target_link_libraries(pulseview-test
+	${Boost_LIBRARIES}
+	${PKGDEPS_STATIC_LIBRARIES}
+	${QT_LIBRARIES}
+)
+else(WIN32)
 target_link_libraries(pulseview-test
-	${PULSEVIEW_LINK_LIBS}
+	${Boost_LIBRARIES}
+	${PKGDEPS_LIBRARIES}
+	${QT_LIBRARIES}
 )
+endif(WIN32)
 
-# TODO: Explain what we use this testing for
 enable_testing()
 add_test(test ${CMAKE_CURRENT_BINARY_DIR}/pulseview-test)
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to