Merge pull request #4 from milkcocoa0902/cmake_modification
Cmake modification
This commit is contained in:
+51
-11
@@ -22,7 +22,11 @@ set(CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -DDEBUG")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -march=native -DNDEBUG")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-O1,--sort-common,--as-needed,-z,relro")
|
||||
if(UNIX)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-O1,--sort-common,--as-needed,-z,relro")
|
||||
elseif(WIN32 OR APPLE)
|
||||
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-O1,--sort-common,--as-needed")
|
||||
endif()
|
||||
|
||||
if(CMAKE_GENERATOR STREQUAL "Ninja")
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
@@ -49,28 +53,64 @@ if(ENABLE_CODE_COVERAGE)
|
||||
endif()
|
||||
|
||||
# Required libraries
|
||||
find_package(Boost 1.71.0 COMPONENTS unit_test_framework REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
if(NOT OPENSSL_FOUND)
|
||||
if(ENABLE_TEST)
|
||||
if(NOT (UNIX OR APPLE))
|
||||
message(FAITAL_ERROR "unit test is NOT supported on Windows")
|
||||
endif()
|
||||
find_package(Boost 1.71.0 COMPONENTS unit_test_framework REQUIRED)
|
||||
# Enable CTest
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
|
||||
# Search OpenSSL
|
||||
if(UNIX OR APPLE)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
if(NOT OPENSSL_FOUND)
|
||||
message(FATAL_ERROR "Fail to find OpenSSL") # exit
|
||||
endif()
|
||||
set(OPENSSL_LIBRARIES OpenSSL::SSL OpenSSL::Crypto)
|
||||
elseif(WIN32)
|
||||
if(NOT OPENSSL_ROOT_DIR)
|
||||
message(FATAL_ERROR "Fail to find OpenSSL") # exit
|
||||
endif()
|
||||
set(OPENSSL_INCLUDE_DIR "${OPENSSL_ROOT_DIR}/include")
|
||||
set(OPENSSL_LIBRARIES "${OPENSSL_ROOT_DIR}/lib/libssl.dll.a" "${OPENSSL_ROOT_DIR}/lib/libcrypto.dll.a" )
|
||||
file(GLOB DLL ${OPENSSL_ROOT_DIR}/*.dll)
|
||||
file(COPY ${DLL} DESTINATION ${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
message(STATUS "OPENSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
|
||||
message(STATUS "OpenSSL Libraries : ${OPENSSL_LIBRARIES}")
|
||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||
|
||||
find_package(CURL REQUIRED)
|
||||
if(NOT CURL_FOUND)
|
||||
message(FATAL_ERROR "Fail to find OpenSSL") # exit
|
||||
|
||||
# Search cURL library
|
||||
if(UNIX OR APPLE)
|
||||
find_package(CURL REQUIRED)
|
||||
if(NOT CURL_FOUND)
|
||||
message(FATAL_ERROR "Fail to find cURL library") # exit
|
||||
endif()
|
||||
elseif(WIN32)
|
||||
if(NOT CURL_ROOT_DIR)
|
||||
message(FATAL_ERROR "Fail to find cURL library") # exit
|
||||
endif()
|
||||
add_definitions(-DCURL_STATICLIB)
|
||||
set(CURL_INCLUDE_DIRS "${CURL_ROOT_DIR}/include")
|
||||
set(CURL_LIBRARIES "${CURL_ROOT_DIR}/lib/libcurl.dll.a")
|
||||
file(GLOB DLL ${CURL_ROOT_DIR}/bin/*.dll)
|
||||
file(COPY ${DLL} DESTINATION ${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
message(STATUS "CURL_INCLUDE_DIR: ${CURL_INCLUDE_DIRS}")
|
||||
message(STATUS "CURL_LIBRARIES: ${CURL_LIBRARIES}")
|
||||
include_directories(${CURL_INCLUDE_DIRS})
|
||||
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/src
|
||||
${PROJECT_SOURCE_DIR}/third
|
||||
)
|
||||
|
||||
# Enable CTest
|
||||
enable_testing()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(test)
|
||||
|
||||
@@ -7,9 +7,38 @@
|
||||
This is a library for using Twitter API from C++
|
||||
|
||||
# Dependency
|
||||
- libcurl
|
||||
- libcurl(openssl version)
|
||||
- libssl
|
||||
|
||||
# Instllation
|
||||
## Ubuntu
|
||||
```
|
||||
# apt install clang cmake git libboost-dev libboost-test-dev libcurl4-openssl-dev libssl-dev nunja-build
|
||||
$ git clone https://github.com/koron0902/CocoaTweet
|
||||
$ cd CocoaTweet // HINT : see bellow for more build faster
|
||||
$ mkdir build
|
||||
$ cd build
|
||||
$ cmake .. -G Ninja
|
||||
$ ninja
|
||||
```
|
||||
|
||||
## Windows
|
||||
T.B.D.
|
||||
|
||||
## HINT
|
||||
in the default, test code also linked when build.
|
||||
you can build more faster modifing CMakeLists.txt
|
||||
```
|
||||
$ vi CMakeLists.txt (or other editor you like)
|
||||
|
||||
// line 73
|
||||
# enable_testing()
|
||||
|
||||
// line 76
|
||||
# add_subdirectory(test)
|
||||
|
||||
```
|
||||
|
||||
# Features
|
||||
you can use these endpoint
|
||||
- statuses/update
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
file(GLOB_RECURSE SOURCES ./*.cc)
|
||||
add_library(lib-cocoatweet ${SOURCES})
|
||||
|
||||
|
||||
target_link_libraries(lib-cocoatweet PUBLIC
|
||||
Boost::boost
|
||||
OpenSSL::SSL
|
||||
OpenSSL::Crypto
|
||||
${OPENSSL_LIBRARIES}
|
||||
${CURL_LIBRARIES}
|
||||
)
|
||||
|
||||
if(ENABLE_TEST)
|
||||
target_link_libraries(lib-cocoatweet PUBLIC Boost::boost)
|
||||
endif()
|
||||
|
||||
target_include_directories(lib-cocoatweet PUBLIC ${PROJECT_SOURCE_DIR}/src)
|
||||
set_target_properties(lib-cocoatweet PROPERTIES OUTPUT_NAME cocoatweet)
|
||||
|
||||
Reference in New Issue
Block a user