66 lines
2.2 KiB
CMake
66 lines
2.2 KiB
CMake
cmake_minimum_required (VERSION 2.6 FATAL_ERROR)
|
|
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;Final" CACHE STRING "possible configurations" FORCE)
|
|
list(FIND CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE}" BuildTypeCurr)
|
|
if ("${BuildTypeCurr}" LESS "0")
|
|
set(CMAKE_BUILD_TYPE "Final" CACHE STRING "Build type defaults to Final" FORCE)
|
|
endif()
|
|
unset(BuildTypeCurr)
|
|
set_property (GLOBAL PROPERTY DEBUG_CONFIGURATIONS "Debug;Release")
|
|
project (WordReference CXX)
|
|
|
|
include(ExternalProject)
|
|
|
|
set (LIBJSON_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/libjson)
|
|
set (LIBJSON_LIB_DIR ${PROJECT_SOURCE_DIR}/libjson)
|
|
set (LIBJSON_CODE_DIR ${PROJECT_SOURCE_DIR}/libjson)
|
|
set (${PROJECT_NAME}_Version_Major 0)
|
|
set (${PROJECT_NAME}_Version_Minor 1)
|
|
set (${PROJECT_NAME}_App_Name "\"${PROJECT_NAME}\"")
|
|
string (TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER)
|
|
set (${PROJECT_NAME}_SourceCodeVar "\"\$${PROJECT_NAME_UPPER}_SOURCE_PATH\"")
|
|
|
|
find_package(CURL REQUIRED)
|
|
find_package(Boost 1.32.0 REQUIRED program_options)
|
|
|
|
set (GNU_COMMON_C_FLAGS "-Werror -msse2")
|
|
set (GNU_COMMON_CXX_FLAGS "-std=c++11 -Werror -msse2 -fexceptions")
|
|
foreach (ConfigType ${CMAKE_CONFIGURATION_TYPES})
|
|
string(TOUPPER ${ConfigType} ConfigTypeUpper)
|
|
set(CMAKE_CXX_FLAGS_${ConfigTypeUpper} "${CMAKE_CXX_FLAGS_${ConfigTypeUpper}} ${GNU_COMMON_CXX_FLAGS} -DDUCK_${ConfigTypeUpper}")
|
|
set(CMAKE_C_FLAGS_${ConfigTypeUpper} "${CMAKE_C_FLAGS_${ConfigTypeUpper}} ${GNU_COMMON_C_FLAGS} -DDUCK_${ConfigTypeUpper}")
|
|
endforeach()
|
|
|
|
add_definitions(-DJSON_ISO_STRICT)
|
|
include_directories(SYSTEM
|
|
${CURL_INCLUDE_DIRS}
|
|
${LIBJSON_INCLUDE_DIRS}
|
|
${Boost_INCLUDE_DIRS}
|
|
)
|
|
include_directories(
|
|
.
|
|
)
|
|
link_directories(
|
|
${LIBJSON_LIB_DIR}
|
|
${Boost_LIBRARY_DIRS}
|
|
)
|
|
|
|
add_custom_target(build_json ALL
|
|
COMMAND ${CMAKE_MAKE_PROGRAM}
|
|
WORKING_DIRECTORY ${LIBJSON_CODE_DIR}
|
|
COMMENT "Original libjson makefile target"
|
|
)
|
|
|
|
add_library(json STATIC IMPORTED)
|
|
set_property(TARGET json APPEND PROPERTY IMPORTED_CONFIGURATIONS NOCONFIG)
|
|
set_target_properties(json PROPERTIES IMPORTED_LOCATION_NOCONFIG "${LIBJSON_LIB_DIR}/libjson.a")
|
|
add_dependencies(json build_json)
|
|
|
|
add_executable(${PROJECT_NAME}
|
|
main.cpp
|
|
WordReference.cpp
|
|
)
|
|
target_link_libraries(${PROJECT_NAME}
|
|
${Boost_LIBRARIES}
|
|
${CURL_LIBRARIES}
|
|
json
|
|
)
|