Browse Source

Add config.h generation and wrapper header, currently only for OBS_VERSION

BtbN 11 years ago
parent
commit
044680f0b8
5 changed files with 47 additions and 4 deletions
  1. 4 2
      CMakeLists.txt
  2. 1 1
      cmake/Modules/ObsCpack.cmake
  3. 10 1
      libobs/CMakeLists.txt
  4. 5 0
      libobs/config.h.in
  5. 27 0
      libobs/obs-config.h

+ 4 - 2
CMakeLists.txt

@@ -11,8 +11,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
 include(ObsHelpers)
 include(ObsCpack)
 
-add_definitions(-DOBS_VERSION="${OBS_VERSION}")
-
 if(MSVC AND NOT EXISTS "${CMAKE_BINARY_DIR}/ALL_BUILD.vcxproj.user")
 	file(GENERATE
 		OUTPUT "${CMAKE_BINARY_DIR}/ALL_BUILD.vcxproj.user"
@@ -55,6 +53,10 @@ endif()
 
 if(NOT INSTALLER_RUN)
 	add_subdirectory(deps)
+
+	add_definitions(-DHAVE_CONFIG_H=1)
+	include_directories("${CMAKE_BINARY_DIR}/config")
+
 	add_subdirectory(libobs)
 
 	if(WIN32)

+ 1 - 1
cmake/Modules/ObsCpack.cmake

@@ -15,7 +15,7 @@ set(CPACK_PACKAGE_VERSION_PATCH "1")
 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
 
 if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
-	execute_process(COMMAND git describe --always
+	execute_process(COMMAND git describe --always --dirty=-modified
 		OUTPUT_VARIABLE OBS_VERSION
 		WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
 		OUTPUT_STRIP_TRAILING_WHITESPACE)

+ 10 - 1
libobs/CMakeLists.txt

@@ -17,7 +17,6 @@ include_directories(${Libavformat_INCLUDE_DIR})
 add_definitions(${Libavformat_DEFINITIONS})
 
 add_definitions(-DLIBOBS_EXPORTS)
-add_definitions(-DPTW32_STATIC_LIB)
 
 if(WIN32)
 	set(libobs_PLATFORM_SOURCES
@@ -27,6 +26,8 @@ if(WIN32)
 	set(libobs_PLATFORM_DEPS
 		w32-pthreads
 		winmm.lib)
+
+	add_definitions(-DPTW32_STATIC_LIB)
 elseif(APPLE)
 	set(libobs_PLATFORM_SOURCES
 		obs-cocoa.c
@@ -57,6 +58,14 @@ if(MSVC)
 	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHc-")
 endif()
 
+configure_file(
+	"${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
+	"${CMAKE_BINARY_DIR}/config/config.h")
+
+set(libobs_config_HEADERS
+	config.h
+	obs-config.h)
+
 set(libobs_callback_SOURCES
 	callback/calldata.c
 	callback/decl.c

+ 5 - 0
libobs/config.h.in

@@ -0,0 +1,5 @@
+
+#pragma once
+
+#define OBS_VERSION "@OBS_VERSION@"
+

+ 27 - 0
libobs/obs-config.h

@@ -0,0 +1,27 @@
+/******************************************************************************
+    Copyright (C) 2014 by Hugh Bailey <[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/>.
+******************************************************************************/
+
+#pragma once
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#else
+
+#define OBS_VERSION "unknown"
+
+#endif
+