-
Notifications
You must be signed in to change notification settings - Fork 725
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67063c7
commit 7fe61ca
Showing
10 changed files
with
159 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
# create by lsm <[email protected]> | ||
# cmake | ||
# LICENSE: Apache License 2.0 | ||
# Copyright (c) Hardy Simpson | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#/ | ||
|
||
cmake_minimum_required(VERSION 2.8.5) | ||
|
||
|
@@ -9,20 +22,15 @@ message(STATUS "path : ${CMAKE_FIND_ROOT_PATH}") | |
|
||
set(CMAKE_MODULE_PATH ${zlog_SOURCE_DIR}/cmake) | ||
|
||
#===================================== | ||
# version of zlog | ||
#===================================== | ||
SET(CPACK_PACKAGE_VERSION_MAJOR "1") | ||
SET(CPACK_PACKAGE_VERSION_MINOR "2") | ||
SET(CPACK_PACKAGE_VERSION_PATCH "12") | ||
SET(CPACK_RPM_PACKAGE_RELEASE 1) #release version. | ||
SET(CPACK_RPM_PACKAGE_RELEASE 1) # release version. | ||
SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") | ||
SET(zlog_ver ${CPACK_PACKAGE_VERSION}) | ||
SET(zlog_so_ver ${CPACK_PACKAGE_VERSION_MAJOR}) | ||
SET(ZLOG_VERSION ${CPACK_PACKAGE_VERSION}) | ||
SET(ZLOG_SO_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}) | ||
|
||
#======================================================= | ||
|
||
message(STATUS "plateform : ${CMAKE_SYSTEM}") | ||
message(STATUS "platform : ${CMAKE_SYSTEM}") | ||
|
||
add_definitions("-g -Wall -Wstrict-prototypes") | ||
set(CMAKE_C_FLAGS "-std=c99 -pedantic -D_DEFAULT_SOURCE") | ||
|
@@ -31,48 +39,28 @@ set(CMAKE_C_FLAGS_RELEASE "-O2") | |
|
||
if (WIN32) | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWINVER=0x0500 -D_WIN32_WINNT=0x0500 ") | ||
endif() | ||
|
||
#===================================================== | ||
# include dir | ||
# include_directories(include) | ||
#===================================================== | ||
endif () | ||
|
||
#===================================================== | ||
# lib output path. | ||
cmake_policy(SET CMP0015 NEW) | ||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${zlog_BINARY_DIR}/lib") | ||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${zlog_BINARY_DIR}/lib") | ||
# bin output path. | ||
|
||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${zlog_BINARY_DIR}/bin") | ||
#===================================================== | ||
|
||
#===================================================== | ||
# link path. | ||
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) | ||
#===================================================== | ||
|
||
#===================================================== | ||
# library depend. | ||
set(Need_THREAD 1) | ||
|
||
if (WIN32) | ||
set(Need_UNIXEM 1) | ||
endif() | ||
endif () | ||
|
||
include(cmake/LoadLibraries.cmake) | ||
#===================================================== | ||
|
||
#======================================================== | ||
# sub dir | ||
add_subdirectory(src) | ||
add_subdirectory(cpack) | ||
#======================================================== | ||
|
||
#======================================================== | ||
# for unittest, call "cmake .. -DUNIT_TEST=on" | ||
if(UNIT_TEST) | ||
if (UNIT_TEST) | ||
enable_testing() | ||
add_subdirectory(test) | ||
endif() | ||
#======================================================== | ||
|
||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
#======================================================= | ||
# ======================================================= | ||
# 支持多线程 | ||
# 对于需要多线程的库,使用以下命令包含连接库: | ||
# target_link_libraries(xxx ${CMAKE_THREAD_PREFER_PTHREAD}) | ||
#======================================================= | ||
if(Need_THREAD) | ||
# ======================================================= | ||
if (Need_THREAD) | ||
find_package(Threads REQUIRED) | ||
if(NOT CMAKE_THREAD_PREFER_PTHREAD) | ||
|
||
if (NOT CMAKE_THREAD_PREFER_PTHREAD) | ||
set(CMAKE_THREAD_PREFER_PTHREAD ${CMAKE_THREAD_LIBS_INIT}) | ||
endif() | ||
endif () | ||
|
||
message(STATUS "thread lib : ${CMAKE_THREAD_PREFER_PTHREAD}") | ||
endif(Need_THREAD) | ||
endif (Need_THREAD) | ||
|
||
if(Need_UNIXEM) | ||
if (Need_UNIXEM) | ||
find_package(Unixem) | ||
|
||
if (NOT UNIXEM_FOUND) | ||
message(FATAL_ERROR "unixem lib not found!") | ||
endif() | ||
endif() | ||
endif () | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,42 @@ | ||
# create by lsm <[email protected]> | ||
|
||
#====================================== | ||
# vendor info | ||
#====================================== | ||
SET(CPACK_PACKAGE_VENDOR "zlog") | ||
SET(CPACK_PACKAGE_CONTACT "[email protected]") | ||
SET(CPACK_RPM_PACKAGE_LICENSE "Apache License Version 2.0") | ||
|
||
#====================================== | ||
# default install prefix. | ||
#====================================== | ||
SET(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local") | ||
SET(CPACK_RPM_PACKAGE_GROUP "System Environment/Base") | ||
|
||
#================================= | ||
# set platform. | ||
#================================= | ||
message(STATUS "system process is ${CMAKE_HOST_SYSTEM_PROCESSOR}") | ||
message(STATUS "system process is ${CMAKE_SYSTEM_PROCESSOR}") | ||
|
||
IF (NOT CMAKE_SYSTEM_PROCESSOR) | ||
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR}) | ||
endif() | ||
endif () | ||
|
||
IF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64|amd64") | ||
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64|amd64") | ||
set(CMAKE_SYSTEM_PROCESSOR x86_64) | ||
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE amd64) | ||
SET(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64") | ||
ELSEIF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc64|ppc64") | ||
ELSEIF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc64|ppc64") | ||
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE powerpc64) | ||
SET(CPACK_RPM_PACKAGE_ARCHITECTURE "ppc64") | ||
ELSEIF(${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc|ppc") | ||
ELSEIF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "powerpc|ppc") | ||
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE powerpc) | ||
SET(CPACK_RPM_PACKAGE_ARCHITECTURE "ppc") | ||
ELSE() | ||
ELSE () | ||
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE i386) | ||
SET(CPACK_RPM_PACKAGE_ARCHITECTURE i386) | ||
ENDIF() | ||
SET(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") | ||
ENDIF () | ||
|
||
SET(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") | ||
SET(CPACK_TOPLEVEL_TAG "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}") | ||
|
||
#====================================== | ||
# generator setting. | ||
#====================================== | ||
SET(CPACK_CMAKE_GENERATOR "Unix Makefiles") | ||
|
||
if (WIN32) | ||
SET(CPACK_GENERATOR "NSIS") | ||
else() | ||
else () | ||
SET(CPACK_GENERATOR "RPM;DEB") | ||
endif() | ||
endif () | ||
|
||
#====================================== | ||
# package. | ||
#====================================== | ||
add_subdirectory(zlog) |
Oops, something went wrong.