[asterisk-scf-commits] asterisk-scf/integration/pjproject.git branch "cmake" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Fri Jul 1 18:16:55 CDT 2011
branch "cmake" has been updated
via c99457a1afefae7290bcf7c2580b4dd93211cef4 (commit)
via 5abedcc49db4fdc89569b6e29e0fea8dfe8a4dc9 (commit)
from e2501775db2bbcba05ed11235f37069f3489b95d (commit)
Summary of changes:
CMakeLists.txt | 216 +++++++++++++++++++++++++++-------
cmake/modules/pjproject.cmake | 80 +++++++++++++
pjlib/include/pj/compat/m_auto.h.in | 4 +-
pjlib/include/pj/compat/os_auto.h.in | 80 ++++++------
4 files changed, 293 insertions(+), 87 deletions(-)
create mode 100644 cmake/modules/pjproject.cmake
- Log -----------------------------------------------------------------
commit c99457a1afefae7290bcf7c2580b4dd93211cef4
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Fri Jul 1 18:14:31 2011 -0500
Work in progress:
* Reorder CMakeLists.txt to match order of existing configure script where
it makes sense to do so.
* Add helper functions for header file and library checks to emulate Autoconf
behavior.
* Add most library and header file checks.
* Modified header files that get configured to use CMake syntax for
replacements.
* Added 'enable floating point' option (defaulting to ON, as in the existing
configure script).
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a33a8cb..79d5c56 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,11 +1,19 @@
cmake_minimum_required(VERSION 2.8)
project("pjproject" C)
+include(CheckIncludeFile)
+include(CheckLibraryExists)
+include(CheckCSourceCompiles)
+include(CheckFunctionExists)
+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
include("${CMAKE_SOURCE_DIR}/cmake/modules/pjproject.cmake")
+
if(CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "This project must not be built in the source directory")
endif()
+
message(STATUS "Installation prefix set to ${CMAKE_INSTALL_PREFIX}")
+
if(NOT CMAKE_BUILD_TYPE)
__pj_set_cache_string(CMAKE_BUILD_TYPE debug "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Profile.")
endif()
@@ -13,9 +21,6 @@ string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
if(WIN32 AND ${CMAKE_BUILD_TYPE} STREQUAL profile)
message(FATAL_ERROR "Profile builds not supported")
endif()
-if(UNIX)
- set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS true)
-endif()
if(${CMAKE_BUILD_TYPE} STREQUAL profile)
message(STATUS "Disabling shared libs.")
__pj_set_cache_bool(BUILD_SHARED_LIBS false "Enables building shared libraries.")
@@ -23,29 +28,40 @@ elseif(NOT DEFINED BUILD_SHARED_LIBS)
message(STATUS "Enabling shared libs.")
__pj_set_cache_bool(BUILD_SHARED_LIBS true "Enables building shared libraries.")
endif()
+
+if(UNIX)
+ set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS true)
+endif()
+
if(UNIX AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
add_custom_target(update COMMAND git pull WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" COMMENT "Updating clone")
add_custom_target(pull COMMAND git pull WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" COMMENT "Updating clone")
endif()
-configure_file(
- "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/cmake_uninstall.cmake.in"
- "${CMAKE_CURRENT_BINARY_DIR}/cmake/modules/cmake_uninstall.cmake"
- IMMEDIATE @ONLY
- )
add_custom_target(
uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake/modules/cmake_uninstall.cmake"
)
+
set(CMAKE_INCLUDE_CURRENT_DIR true)
+
if(WIN32)
__pj_set_cache_string(CMAKE_DEBUG_POSTFIX "-debug" "" ADVANCED)
__pj_set_cache_string(CMAKE_RELEASE_POSTFIX "-release" "" ADVANCED)
endif()
-configure_file(pjlib/include/pj/compat/os_auto.h.in pjlib/include/pj/compat/os_auto.h ESCAPE_QUOTES @ONLY)
-configure_file(pjlib/include/pj/compat/m_auto.h.in pjlib/include/pj/compat/m_auto.h ESCAPE_QUOTES @ONLY)
-configure_file(pjmedia/include/pjmedia/config_auto.h.in pjmedia/include/pjmedia/config_auto.h ESCAPE_QUOTES @ONLY)
-configure_file(pjmedia/include/pjmedia-codec/config_auto.h.in pjmedia/include/pjmedia-codec/config_auto.h ESCAPE_QUOTES @ONLY)
-configure_file(pjsip/include/pjsip/sip_autoconf.h.in pjsip/include/pjsip/sip_autoconf.h ESCAPE_QUOTES @ONLY)
+
+__pj_append_to_var(CMAKE_C_FLAGS ${c_flags})
+__pj_append_to_var(CMAKE_C_FLAGS_DEBUG ${c_flags_debug})
+__pj_append_to_var(CMAKE_C_FLAGS_PROFILE ${c_flags_profile} ${c_flags_debug})
+__pj_append_to_var(CMAKE_EXE_LINKER_FLAGS ${linker_flags})
+__pj_append_to_var(CMAKE_SHARED_LINKER_FLAGS ${linker_flags})
+
+set(ac_pjdir "${CMAKE_CURRENT_SOURCE_DIR}")
+
+if(UNIX)
+ include(FindPkgConfig)
+ pkg_check_modules(LIBUUID uuid)
+endif()
+
find_package(Threads REQUIRED)
if(CMAKE_THREAD_LIBS_INIT)
if(NOT CMAKE_HAVE_THREADS_LIBRARY)
@@ -58,26 +74,129 @@ if(CMAKE_COMPILER_IS_GNUCC)
list(APPEND c_flags_debug "-Wall" "-g3")
list(APPEND c_flags_profile "-ftest-coverage" "-fprofile-arcs")
endif()
-__pj_append_to_var(CMAKE_C_FLAGS ${c_flags})
-__pj_append_to_var(CMAKE_C_FLAGS_DEBUG ${c_flags_debug})
-__pj_append_to_var(CMAKE_C_FLAGS_PROFILE ${c_flags_profile} ${c_flags_debug})
-__pj_append_to_var(CMAKE_EXE_LINKER_FLAGS ${linker_flags})
-__pj_append_to_var(CMAKE_SHARED_LINKER_FLAGS ${linker_flags})
-# this entire block may be only useful for PJMEDIA
-if(UNIX)
- include(FindPkgConfig)
- include(CheckIncludeFiles)
- include(CheckLibraryExists)
- pkg_check_modules(LIBUUID uuid)
- if(LIBUUID_LIBRARIES)
- check_include_files(uuid/uuid.h HAVE_UUID_H)
- check_library_exists(uuid uuid_generate "${LIBUUID_LIBRARY_DIRS}" HAVE_LIBUUID)
- if(HAVE_UUID_H AND HAVE_LIBUUID)
- list(APPEND ac_os_targets "guid_uuid")
- link_directories(${LIBUUID_LIBRARY_DIRS})
- else()
- list(APPEND ac_os_targets "guid_simple")
- endif()
-# set(PJMEDIA_LIBRARIES ${LIBUUID_LIBRARIES})
+
+__pj_check_library(wsock32 puts)
+__pj_check_library(wsock32 puts)
+__pj_check_library(ws2_32 puts)
+__pj_check_library(ole32 puts)
+__pj_check_library(winmm puts)
+__pj_check_library(socket puts)
+__pj_check_library(rt puts)
+__pj_check_library(nsl puts)
+__pj_check_library(uuid uuid_generate "${LIBUUID_LIBRARY_DIRS}" HAVE_LIBUUID)
+
+message(STATUS "Target CPU type is ${CMAKE_SYSTEM_PROCESSOR}")
+set(PJ_M_NAME ${CMAKE_SYSTEM_PROCESSOR})
+
+message(STATUS "Pool memory alignment is ${CMAKE_SIZEOF_VOID_P} bytes")
+set(PJ_POOL_ALIGNMENT ${CMAKE_SIZEOF_VOID_P})
+
+option(PJ_HAS_FLOATING_POINT "Enable floating point math usage" ON)
+if(PJ_HAS_FLOATING_POINT)
+ __pj_check_library(m fmod)
+endif()
+
+__pj_check_header(arpa/inet.h PJ_HAS_ARPA_INET_H)
+__pj_check_header(assert.h PJ_HAS_ASSERT_H)
+__pj_check_header(ctype.h PJ_HAS_CTYPE_H)
+if(WIN32)
+ set(PJ_HAS_ERRNO_H 0)
+else()
+ __pj_check_header(errno.h PJ_HAS_ERRNO_H)
+endif()
+__pj_check_header(fcntl.h PJ_HAS_FCNTL_H)
+check_function_exists(getifaddrs PJ_HAS_GETIFADDRS)
+if(PJ_HAS_GETIFADDRS)
+ __pj_check_header(ifaddrs.h PJ_HAS_IFADDRS_H)
+endif()
+__pj_check_header(limits.h PJ_HAS_LIMITS_H)
+__pj_check_header(linux/socket.h PJ_HAS_LINUX_SOCKET_H)
+__pj_check_header(malloc.h PJ_HAS_MALLOC_H)
+__pj_check_header(netdb.h PJ_HAS_NETDB_H)
+__pj_check_header(netinet/in_systm.h PJ_HAS_NETINET_IN_SYSTM_H)
+__pj_check_header(netinet/in.h PJ_HAS_NETINET_IN_H)
+__pj_check_header(netinet/tcp.h PJ_HAS_NETINET_TCP_H)
+__pj_check_header(semaphore.h PJ_HAS_SEMAPHORE_H)
+__pj_check_header(setjmp.h PJ_HAS_SETJMP_H)
+__pj_check_header(stdarg.h PJ_HAS_STDARG_H)
+__pj_check_header(stddef.h PJ_HAS_STDDEF_H)
+__pj_check_header(stdio.h PJ_HAS_STDIO_H)
+__pj_check_header(stdint.h PJ_HAS_STDINT_H)
+__pj_check_header(stdlib.h PJ_HAS_STDLIB_H)
+__pj_check_header(string.h PJ_HAS_STRING_H)
+__pj_check_header(sys/ioctl.h PJ_HAS_SYS_IOCTL_H)
+__pj_check_header(sys/select.h PJ_HAS_SYS_SELECT_H)
+__pj_check_header(sys/socket.h PJ_HAS_SYS_SOCKET_H)
+__pj_check_header(sys/time.h PJ_HAS_SYS_TIME_H)
+__pj_check_header(sys/timeb.h PJ_HAS_SYS_TIMEB_H)
+__pj_check_header(sys/types.h PJ_HAS_SYS_TYPES_H)
+__pj_check_header(sys/filio.h PJ_HAS_SYS_FILIO_H)
+__pj_check_header(sys/sockio.h PJ_HAS_SYS_SOCKIO_H)
+__pj_check_header(sys/utsname.h PJ_HAS_SYS_UTSNAME_H)
+__pj_check_header(time.h PJ_HAS_TIME_H)
+__pj_check_header(unistd.h PJ_HAS_UNISTD_H)
+__pj_check_header(uuid/uuid.h HAVE_UUID_H)
+__pj_check_header(winsock.h PJ_HAS_WINSOCK_H)
+__pj_check_header(winsock2.h PJ_HAS_WINSOCK2_H)
+__pj_check_header(ws2tcpip.h PJ_HAS_WS2TCPIP_H)
+
+# This check is out of order because it relies on the check for sys/types.h
+__pj_check_header(netinet/ip.h PJ_HAS_NETINET_IP_H
+ "
+ #if PJ_HAS_SYS_TYPES_H
+ # include <sys/types.h>
+ #endif
+ #if PJ_HAS_NETINET_IN_SYSTM_H
+ # include <netinet/in_systm.h>
+ #endif
+ #if PJ_HAS_NETINET_IN_H
+ # include <netinet/in.h>
+ #endif
+ "
+ )
+
+# This check is out of order because it relies on the checks for winsock.h and winsock2.h
+__pj_check_header(mswsock.h PJ_HAS_MSWSOCK_H
+ "
+ #if PJ_HAS_WINSOCK2_H
+ # include <winsock2.h>
+ #elif PJ_HAS_WINSOCK_H
+ # include <winsock.h>
+ #endif
+ "
+ )
+
+# This check is out of order because it relies on the checks for sys/types.h and sys/socket.h
+__pj_check_header(net/if.h PJ_HAS_NET_IF_H
+ "
+ #if PJ_HAS_SYS_TYPES_H
+ # include <sys/types.h>
+ #endif
+ #if PJ_HAS_SYS_SOCKET_H
+ # include <sys/socket.h>
+ #endif
+ "
+ )
+
+if(HAVE_UUID_H AND HAVE_LIBUUID)
+ list(APPEND ac_os_targets "guid_uuid")
+ if(LIBUUID_LIBRARY_DIRS)
+ link_directories(${LIBUUID_LIBRARY_DIRS})
endif()
+else()
+ list(APPEND ac_os_targets "guid_simple")
endif()
+
+configure_file(pjlib/include/pj/compat/os_auto.h.in pjlib/include/pj/compat/os_auto.h ESCAPE_QUOTES @ONLY)
+configure_file(pjlib/include/pj/compat/m_auto.h.in pjlib/include/pj/compat/m_auto.h ESCAPE_QUOTES @ONLY)
+configure_file(pjmedia/include/pjmedia/config_auto.h.in pjmedia/include/pjmedia/config_auto.h ESCAPE_QUOTES @ONLY)
+configure_file(pjmedia/include/pjmedia-codec/config_auto.h.in pjmedia/include/pjmedia-codec/config_auto.h ESCAPE_QUOTES @ONLY)
+configure_file(pjsip/include/pjsip/sip_autoconf.h.in pjsip/include/pjsip/sip_autoconf.h ESCAPE_QUOTES @ONLY)
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/cmake_uninstall.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake/modules/cmake_uninstall.cmake"
+ IMMEDIATE @ONLY
+ )
+
+message(STATUS "CMAKE_STANDARD_LIBRARIES: ${CMAKE_STANDARD_LIBRARIES}")
+message(STATUS "CMAKE_REQUIRED_DEFINITIONS: ${CMAKE_REQUIRED_DEFINITIONS}")
diff --git a/cmake/modules/pjproject.cmake b/cmake/modules/pjproject.cmake
index 208a8d8..3412bb0 100644
--- a/cmake/modules/pjproject.cmake
+++ b/cmake/modules/pjproject.cmake
@@ -1,3 +1,34 @@
+include(CheckLibraryExists)
+
+function(__pj_check_library LIBRARY FUNCTION)
+ string(TOUPPER ${LIBRARY} libupper)
+ check_library_exists(${LIBRARY} ${FUNCTION} "" HAVE_LIB${libupper})
+ if(HAVE_LIB${libupper})
+ set(HAVE_LIB${libupper} ${HAVE_LIB${libupper}} PARENT_SCOPE)
+ __pj_prepend_to_var(CMAKE_STANDARD_LIBRARIES ${LIBRARY})
+ set(CMAKE_STANDARD_LIBRARIES ${CMAKE_STANDARD_LIBRARIES} PARENT_SCOPE)
+ endif()
+endfunction()
+
+function(__pj_check_header HEADER VARIABLE)
+ if(NOT ARGN)
+ check_include_file(${HEADER} ${VARIABLE})
+ else()
+ check_c_source_compiles("
+ ${ARGV2}
+ #include <${HEADER}>
+ void main() {}
+ "
+ ${VARIABLE}
+ )
+ endif()
+ if(${VARIABLE})
+ set(${VARIABLE} ${${VARIABLE}} PARENT_SCOPE)
+ __pj_append_to_var(CMAKE_REQUIRED_DEFINITIONS "-D${VARIABLE}")
+ set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} PARENT_SCOPE)
+ endif()
+endfunction()
+
function(__pj_set_cache_bool var value reason)
set("${var}" "${value}" CACHE BOOL "${reason}" FORCE)
foreach(item ${ARGN})
@@ -40,3 +71,10 @@ function(__pj_append_to_var VAR)
endforeach()
set(${VAR} "${${VAR}} ${_altv}" PARENT_SCOPE)
endfunction()
+
+function(__pj_prepend_to_var VAR)
+ foreach(item ${ARGN})
+ set(_altv "${_altv} ${item}")
+ endforeach()
+ set(${VAR} "${_altv} ${${VAR}}" PARENT_SCOPE)
+endfunction()
diff --git a/pjlib/include/pj/compat/m_auto.h.in b/pjlib/include/pj/compat/m_auto.h.in
index 48763ea..8e9fda4 100644
--- a/pjlib/include/pj/compat/m_auto.h.in
+++ b/pjlib/include/pj/compat/m_auto.h.in
@@ -25,8 +25,8 @@
* @brief Automatically generated process definition file.
*/
-/* Machine name, filled in by autoconf script */
-#undef PJ_M_NAME
+/* Machine name, filled in by CMake */
+#cmakedefine PJ_M_NAME "@PJ_M_NAME@"
/* Endianness. It's reported on pjsip list on 09/02/13 that autoconf
* endianness detection failed for universal build, so special case
diff --git a/pjlib/include/pj/compat/os_auto.h.in b/pjlib/include/pj/compat/os_auto.h.in
index 5ff2ad4..ae5e614 100644
--- a/pjlib/include/pj/compat/os_auto.h.in
+++ b/pjlib/include/pj/compat/os_auto.h.in
@@ -43,45 +43,45 @@
#endif
/* Headers availability */
-#undef PJ_HAS_ARPA_INET_H
-#undef PJ_HAS_ASSERT_H
-#undef PJ_HAS_CTYPE_H
-#undef PJ_HAS_ERRNO_H
-#undef PJ_HAS_FCNTL_H
-#undef PJ_HAS_LIMITS_H
-#undef PJ_HAS_LINUX_SOCKET_H
-#undef PJ_HAS_MALLOC_H
-#undef PJ_HAS_NETDB_H
-#undef PJ_HAS_NETINET_IN_SYSTM_H
-#undef PJ_HAS_NETINET_IN_H
-#undef PJ_HAS_NETINET_IP_H
-#undef PJ_HAS_NETINET_TCP_H
-#undef PJ_HAS_NET_IF_H
-#undef PJ_HAS_IFADDRS_H
-#undef PJ_HAS_SEMAPHORE_H
-#undef PJ_HAS_SETJMP_H
-#undef PJ_HAS_STDARG_H
-#undef PJ_HAS_STDDEF_H
-#undef PJ_HAS_STDIO_H
-#undef PJ_HAS_STDINT_H
-#undef PJ_HAS_STDLIB_H
-#undef PJ_HAS_STRING_H
-#undef PJ_HAS_SYS_IOCTL_H
-#undef PJ_HAS_SYS_SELECT_H
-#undef PJ_HAS_SYS_SOCKET_H
-#undef PJ_HAS_SYS_TIME_H
-#undef PJ_HAS_SYS_TIMEB_H
-#undef PJ_HAS_SYS_TYPES_H
-#undef PJ_HAS_SYS_FILIO_H
-#undef PJ_HAS_SYS_SOCKIO_H
-#undef PJ_HAS_SYS_UTSNAME_H
-#undef PJ_HAS_TIME_H
-#undef PJ_HAS_UNISTD_H
-
-#undef PJ_HAS_MSWSOCK_H
-#undef PJ_HAS_WINSOCK_H
-#undef PJ_HAS_WINSOCK2_H
-#undef PJ_HAS_WS2TCPIP_H
+#cmakedefine01 PJ_HAS_ARPA_INET_H
+#cmakedefine01 PJ_HAS_ASSERT_H
+#cmakedefine01 PJ_HAS_CTYPE_H
+#cmakedefine01 PJ_HAS_ERRNO_H
+#cmakedefine01 PJ_HAS_FCNTL_H
+#cmakedefine01 PJ_HAS_LIMITS_H
+#cmakedefine01 PJ_HAS_LINUX_SOCKET_H
+#cmakedefine01 PJ_HAS_MALLOC_H
+#cmakedefine01 PJ_HAS_NETDB_H
+#cmakedefine01 PJ_HAS_NETINET_IN_SYSTM_H
+#cmakedefine01 PJ_HAS_NETINET_IN_H
+#cmakedefine01 PJ_HAS_NETINET_IP_H
+#cmakedefine01 PJ_HAS_NETINET_TCP_H
+#cmakedefine01 PJ_HAS_NET_IF_H
+#cmakedefine01 PJ_HAS_IFADDRS_H
+#cmakedefine01 PJ_HAS_SEMAPHORE_H
+#cmakedefine01 PJ_HAS_SETJMP_H
+#cmakedefine01 PJ_HAS_STDARG_H
+#cmakedefine01 PJ_HAS_STDDEF_H
+#cmakedefine01 PJ_HAS_STDIO_H
+#cmakedefine01 PJ_HAS_STDINT_H
+#cmakedefine01 PJ_HAS_STDLIB_H
+#cmakedefine01 PJ_HAS_STRING_H
+#cmakedefine01 PJ_HAS_SYS_IOCTL_H
+#cmakedefine01 PJ_HAS_SYS_SELECT_H
+#cmakedefine01 PJ_HAS_SYS_SOCKET_H
+#cmakedefine01 PJ_HAS_SYS_TIME_H
+#cmakedefine01 PJ_HAS_SYS_TIMEB_H
+#cmakedefine01 PJ_HAS_SYS_TYPES_H
+#cmakedefine01 PJ_HAS_SYS_FILIO_H
+#cmakedefine01 PJ_HAS_SYS_SOCKIO_H
+#cmakedefine01 PJ_HAS_SYS_UTSNAME_H
+#cmakedefine01 PJ_HAS_TIME_H
+#cmakedefine01 PJ_HAS_UNISTD_H
+
+#cmakedefine01 PJ_HAS_MSWSOCK_H
+#cmakedefine01 PJ_HAS_WINSOCK_H
+#cmakedefine01 PJ_HAS_WINSOCK2_H
+#cmakedefine01 PJ_HAS_WS2TCPIP_H
#undef PJ_SOCK_HAS_INET_ATON
#undef PJ_SOCK_HAS_INET_PTON
@@ -166,7 +166,7 @@
#undef PJ_NATIVE_STRING_IS_UNICODE
/* Pool alignment in bytes */
-#undef PJ_POOL_ALIGNMENT
+#cmakedefine PJ_POOL_ALIGNMENT @PJ_POOL_ALIGNMENT@
/* The type of atomic variable value: */
#undef PJ_ATOMIC_VALUE_TYPE
commit 5abedcc49db4fdc89569b6e29e0fea8dfe8a4dc9
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Fri Jul 1 15:53:54 2011 -0500
Work in progress:
* Moved helper functions into a module file
* Used helper functions every place they should be
* Added checking for thread and UUID support
* Added setting of compiler and linker flags
* Added configuration of header files
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c686be2..a33a8cb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,14 +1,13 @@
cmake_minimum_required(VERSION 2.8)
project("pjproject" C)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
+include("${CMAKE_SOURCE_DIR}/cmake/modules/pjproject.cmake")
if(CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "This project must not be built in the source directory")
endif()
message(STATUS "Installation prefix set to ${CMAKE_INSTALL_PREFIX}")
if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE debug CACHE STRING
- "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Profile."
- FORCE)
+ __pj_set_cache_string(CMAKE_BUILD_TYPE debug "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel Profile.")
endif()
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
if(WIN32 AND ${CMAKE_BUILD_TYPE} STREQUAL profile)
@@ -19,14 +18,10 @@ if(UNIX)
endif()
if(${CMAKE_BUILD_TYPE} STREQUAL profile)
message(STATUS "Disabling shared libs.")
- set(BUILD_SHARED_LIBS false CACHE BOOL
- "Enables building shared libraries."
- FORCE)
+ __pj_set_cache_bool(BUILD_SHARED_LIBS false "Enables building shared libraries.")
elseif(NOT DEFINED BUILD_SHARED_LIBS)
message(STATUS "Enabling shared libs.")
- set(BUILD_SHARED_LIBS true CACHE BOOL
- "Enables building shared libraries."
- FORCE)
+ __pj_set_cache_bool(BUILD_SHARED_LIBS true "Enables building shared libraries.")
endif()
if(UNIX AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
add_custom_target(update COMMAND git pull WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" COMMENT "Updating clone")
@@ -41,36 +36,48 @@ add_custom_target(
uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake/modules/cmake_uninstall.cmake"
)
-# set(CMAKE_INCLUDE_CURRENT_DIR true)
+set(CMAKE_INCLUDE_CURRENT_DIR true)
if(WIN32)
__pj_set_cache_string(CMAKE_DEBUG_POSTFIX "-debug" "" ADVANCED)
__pj_set_cache_string(CMAKE_RELEASE_POSTFIX "-release" "" ADVANCED)
endif()
-
-# various helper functions
-function(__pj_set_cache_path var value reason)
- set("${var}" "${value}" CACHE PATH "${reason}" FORCE)
- foreach(item ${ARGN})
- if(item STREQUAL ADVANCED)
- mark_as_advanced("${var}")
- endif()
- endforeach()
-endfunction()
-
-function(__pj_set_cache_filepath var value reason)
- set("${var}" "${value}" CACHE FILEPATH "${reason}" FORCE)
- foreach(item ${ARGN})
- if(item STREQUAL ADVANCED)
- mark_as_advanced("${var}")
- endif()
- endforeach()
-endfunction()
-
-function(__pj_set_cache_string var value reason)
- set("${var}" "${value}" CACHE STRING "${reason}" FORCE)
- foreach(item ${ARGN})
- if(item STREQUAL ADVANCED)
- mark_as_advanced("${var}")
+configure_file(pjlib/include/pj/compat/os_auto.h.in pjlib/include/pj/compat/os_auto.h ESCAPE_QUOTES @ONLY)
+configure_file(pjlib/include/pj/compat/m_auto.h.in pjlib/include/pj/compat/m_auto.h ESCAPE_QUOTES @ONLY)
+configure_file(pjmedia/include/pjmedia/config_auto.h.in pjmedia/include/pjmedia/config_auto.h ESCAPE_QUOTES @ONLY)
+configure_file(pjmedia/include/pjmedia-codec/config_auto.h.in pjmedia/include/pjmedia-codec/config_auto.h ESCAPE_QUOTES @ONLY)
+configure_file(pjsip/include/pjsip/sip_autoconf.h.in pjsip/include/pjsip/sip_autoconf.h ESCAPE_QUOTES @ONLY)
+find_package(Threads REQUIRED)
+if(CMAKE_THREAD_LIBS_INIT)
+ if(NOT CMAKE_HAVE_THREADS_LIBRARY)
+ list(APPEND c_flags "${CMAKE_THREAD_LIBS_INIT}")
+ else()
+ list(APPEND linker_flags "${CMAKE_THREAD_LIBS_INIT}")
+ endif()
+endif()
+if(CMAKE_COMPILER_IS_GNUCC)
+ list(APPEND c_flags_debug "-Wall" "-g3")
+ list(APPEND c_flags_profile "-ftest-coverage" "-fprofile-arcs")
+endif()
+__pj_append_to_var(CMAKE_C_FLAGS ${c_flags})
+__pj_append_to_var(CMAKE_C_FLAGS_DEBUG ${c_flags_debug})
+__pj_append_to_var(CMAKE_C_FLAGS_PROFILE ${c_flags_profile} ${c_flags_debug})
+__pj_append_to_var(CMAKE_EXE_LINKER_FLAGS ${linker_flags})
+__pj_append_to_var(CMAKE_SHARED_LINKER_FLAGS ${linker_flags})
+# this entire block may be only useful for PJMEDIA
+if(UNIX)
+ include(FindPkgConfig)
+ include(CheckIncludeFiles)
+ include(CheckLibraryExists)
+ pkg_check_modules(LIBUUID uuid)
+ if(LIBUUID_LIBRARIES)
+ check_include_files(uuid/uuid.h HAVE_UUID_H)
+ check_library_exists(uuid uuid_generate "${LIBUUID_LIBRARY_DIRS}" HAVE_LIBUUID)
+ if(HAVE_UUID_H AND HAVE_LIBUUID)
+ list(APPEND ac_os_targets "guid_uuid")
+ link_directories(${LIBUUID_LIBRARY_DIRS})
+ else()
+ list(APPEND ac_os_targets "guid_simple")
endif()
- endforeach()
-endfunction()
+# set(PJMEDIA_LIBRARIES ${LIBUUID_LIBRARIES})
+ endif()
+endif()
diff --git a/cmake/modules/pjproject.cmake b/cmake/modules/pjproject.cmake
new file mode 100644
index 0000000..208a8d8
--- /dev/null
+++ b/cmake/modules/pjproject.cmake
@@ -0,0 +1,42 @@
+function(__pj_set_cache_bool var value reason)
+ set("${var}" "${value}" CACHE BOOL "${reason}" FORCE)
+ foreach(item ${ARGN})
+ if(item STREQUAL ADVANCED)
+ mark_as_advanced("${var}")
+ endif()
+ endforeach()
+endfunction()
+
+function(__pj_set_cache_path var value reason)
+ set("${var}" "${value}" CACHE PATH "${reason}" FORCE)
+ foreach(item ${ARGN})
+ if(item STREQUAL ADVANCED)
+ mark_as_advanced("${var}")
+ endif()
+ endforeach()
+endfunction()
+
+function(__pj_set_cache_filepath var value reason)
+ set("${var}" "${value}" CACHE FILEPATH "${reason}" FORCE)
+ foreach(item ${ARGN})
+ if(item STREQUAL ADVANCED)
+ mark_as_advanced("${var}")
+ endif()
+ endforeach()
+endfunction()
+
+function(__pj_set_cache_string var value reason)
+ set("${var}" "${value}" CACHE STRING "${reason}" FORCE)
+ foreach(item ${ARGN})
+ if(item STREQUAL ADVANCED)
+ mark_as_advanced("${var}")
+ endif()
+ endforeach()
+endfunction()
+
+function(__pj_append_to_var VAR)
+ foreach(item ${ARGN})
+ set(_altv "${_altv} ${item}")
+ endforeach()
+ set(${VAR} "${${VAR}} ${_altv}" PARENT_SCOPE)
+endfunction()
-----------------------------------------------------------------------
--
asterisk-scf/integration/pjproject.git
More information about the asterisk-scf-commits
mailing list