toxcore/CMakeLists.txt

68 lines
1.7 KiB
CMake
Raw Normal View History

2013-06-25 08:55:30 +08:00
cmake_minimum_required(VERSION 2.6.0)
2013-07-13 06:31:57 +08:00
2013-07-31 02:41:51 +08:00
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
2013-08-05 09:38:12 +08:00
option(SHARED_TOXCORE "Build Core as a shared library")
2013-08-03 13:17:44 +08:00
2013-08-05 09:38:12 +08:00
if(WIN32)
option(SHARED_LIBSODIUM "Links libsodium as a shared library")
else()
2013-07-30 22:00:55 +08:00
option(USE_NACL "Use NaCl library instead of libsodium")
option(NO_WIDECHAR "Do not use wide char, even if supported")
2013-07-30 22:00:55 +08:00
endif()
#OS X specific
if(APPLE)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /opt/local/lib)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /opt/local/include)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/opt/local/include" )
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/opt/local/lib")
endif()
2013-08-05 09:38:12 +08:00
if(UNIX)
find_package(Cursesw REQUIRED)
2013-08-05 09:38:12 +08:00
endif()
2013-07-31 20:35:06 +08:00
if(USE_NACL)
2013-07-30 22:00:55 +08:00
find_package(NaCl REQUIRED)
include_directories(${NACL_INCLUDE_DIR})
add_definitions(-DVANILLA_NACL)
set(LINK_CRYPTO_LIBRARY ${NACL_LIBRARIES})
2013-08-05 09:38:12 +08:00
else()
find_package(SODIUM REQUIRED)
include_directories(${SODIUM_INCLUDE_DIR})
2013-08-16 15:40:53 +08:00
set(LINK_CRYPTO_LIBRARY ${SODIUM_LIBRARIES})
2013-07-30 22:00:55 +08:00
endif()
2013-07-22 08:41:08 +08:00
#MinGW prints more warnings for -Wall than gcc does, thus causing build to fail
2013-07-18 06:28:53 +08:00
if(NOT WIN32)
if(("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang"))
message(STATUS "==== ${CMAKE_C_COMPILER_ID} detected - Adding compiler flags ====")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
endif()
endif()
2013-07-18 06:06:05 +08:00
macro(linkCoreLibraries exe_name)
add_dependencies(${exe_name} toxcore)
2013-08-05 09:38:12 +08:00
target_link_libraries(${exe_name} toxcore
${LINK_CRYPTO_LIBRARY})
2013-08-05 09:38:12 +08:00
if(WIN32)
target_link_libraries(${exe_name} ws2_32)
2013-07-18 06:06:05 +08:00
endif()
endmacro()
2013-06-26 13:03:35 +08:00
2013-07-18 06:41:58 +08:00
cmake_policy(SET CMP0011 NEW)
2013-07-22 08:41:08 +08:00
add_subdirectory(core)
add_subdirectory(testing)
2013-07-31 02:41:51 +08:00
add_subdirectory(other)
2013-08-01 05:39:09 +08:00
add_subdirectory(docs)
2013-08-09 04:58:54 +08:00
if(UNIX)
add_subdirectory(auto_tests)
endif()