Skip to content

Commit

Permalink
Add conanfile.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
matlo607 committed Feb 28, 2017
1 parent deb7bc1 commit 9d7528d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 18 deletions.
38 changes: 27 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@ else()
message(FATAL_ERROR "CMake build type \"${CMAKE_BUILD_TYPE}\" is not supported")
endif()

message(STATUS "CMAKE_SOURCE_DIR: " ${CMAKE_SOURCE_DIR})

find_program (CONANBIN conan)
if(CONANBIN)
message (STATUS "conan C++ package manager: installed")
find_file (CONANFILE "${CMAKE_SOURCE_DIR}/conanfile.txt")
if (CONANFILE)
message (STATUS "conanfile.txt: found")
endif()
endif()

if (EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
else()
include (CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX ("gsl/span" HAVE_GSL_SPAN)
if(NOT HAVE_GSL_SPAN)
message(FATAL_ERROR "gsl library: <gsl/span> not found")
endif()
endif()

include (CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-std=c++14 COMPILER_SUPPORTS_CXX14)
if(COMPILER_SUPPORTS_CXX14)
Expand All @@ -24,19 +46,13 @@ Please use a different C++ compiler.")
endif()

if(CMAKE_COMPILER_IS_GNUCXX)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -Werror -Wextra")
set (CMAKE_CXX_FLAGS_DEBUG "-g3 -O0 -fno-omit-frame-pointer -DDEBUG")
set (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -Werror -Wextra")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall -Wextra")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3 -O0 -fno-omit-frame-pointer -DDEBUG")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -DNDEBUG")
endif(CMAKE_COMPILER_IS_GNUCXX)

include (CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX ("gsl/span" HAVE_GSL_SPAN)
if(NOT HAVE_GSL_SPAN)
message(FATAL_ERROR "gsl library: <gsl/span> not found")
endif()

message(STATUS "CMAKE_SOURCE_DIR: " ${CMAKE_SOURCE_DIR})

add_subdirectory (src)
add_subdirectory (test)

10 changes: 10 additions & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[requires]
GSL/0.0.0.0-2@TimSimpson/testing
gtest/1.8.0@lasote/stable

[generators]
cmake

[options]
gtest:shared=False

4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ set (SRC_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/SHA512.cpp"
)

add_library (crypto_static STATIC ${SRC_FILES})
add_library (crypto SHARED ${SRC_FILES})
add_library (cryptonew_static STATIC ${SRC_FILES})
add_library (cryptonew SHARED ${SRC_FILES})

13 changes: 8 additions & 5 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
cmake_minimum_required (VERSION 2.8)
project (test-crypto)

find_package (GTest REQUIRED)
include_directories (${GTEST_INCLUDE_DIRS})
if (NOT EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
find_package (GTest REQUIRED)
include_directories (${GTEST_INCLUDE_DIRS})
endif()

set(THREADS_PREFER_PTHREAD_FLAG on)
find_package (Threads REQUIRED)

include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../include")

find_library (CRYPTO_LIBRARY
NAMES crypto #crypto_static
NAMES cryptonew #cryptonew_static
HINTS "${CMAKE_CURRENT_SOURCE_DIR}/../src"
)

Expand All @@ -24,8 +26,9 @@ add_executable (test-crypto ${SRC_FILES})
target_link_libraries (test-crypto
pthread
${GTEST_BOTH_LIBRARIES}
#crypto_static
crypto
#cryptonew_static
cryptonew
${CONAN_LIBS}
)

include (CTest)
Expand Down

0 comments on commit 9d7528d

Please sign in to comment.