diff --git a/src/cpp-utils/CMakeLists.txt b/src/cpp-utils/CMakeLists.txt index 26a625ee..b53836cb 100644 --- a/src/cpp-utils/CMakeLists.txt +++ b/src/cpp-utils/CMakeLists.txt @@ -46,6 +46,6 @@ target_link_libraries(${PROJECT_NAME} PRIVATE curl) find_library(CryptoPP cryptopp) target_link_libraries(${PROJECT_NAME} PRIVATE ${CryptoPP} scrypt) -add_boost(${PROJECT_NAME} filesystem system thread) -enable_style_warnings(${PROJECT_NAME}) -activate_cpp14(${PROJECT_NAME}) +target_add_boost(${PROJECT_NAME} filesystem system thread) +target_enable_style_warnings(${PROJECT_NAME}) +target_activate_cpp14(${PROJECT_NAME}) diff --git a/src/fspp/CMakeLists.txt b/src/fspp/CMakeLists.txt index ed372912..3329473c 100644 --- a/src/fspp/CMakeLists.txt +++ b/src/fspp/CMakeLists.txt @@ -16,9 +16,9 @@ add_library(${PROJECT_NAME} STATIC ${SOURCES}) target_compile_definitions(${PROJECT_NAME} PUBLIC _FILE_OFFSET_BITS=64) target_link_libraries(${PROJECT_NAME} PRIVATE cpp-utils) -add_boost(${PROJECT_NAME} filesystem system thread chrono) -enable_style_warnings(${PROJECT_NAME}) -activate_cpp14(${PROJECT_NAME}) +target_add_boost(${PROJECT_NAME} filesystem system thread chrono) +target_enable_style_warnings(${PROJECT_NAME}) +target_activate_cpp14(${PROJECT_NAME}) if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") if(EXISTS "/usr/local/include/osxfuse") diff --git a/test/cpp-utils/CMakeLists.txt b/test/cpp-utils/CMakeLists.txt index 652fec8a..cdf2ed61 100644 --- a/test/cpp-utils/CMakeLists.txt +++ b/test/cpp-utils/CMakeLists.txt @@ -53,5 +53,5 @@ add_executable(${PROJECT_NAME} ${SOURCES}) target_link_libraries(${PROJECT_NAME} cpp-utils) add_test(${PROJECT_NAME} ${PROJECT_NAME}) -enable_style_warnings(${PROJECT_NAME}) -activate_cpp14(${PROJECT_NAME}) +target_enable_style_warnings(${PROJECT_NAME}) +target_activate_cpp14(${PROJECT_NAME}) diff --git a/test/fspp/CMakeLists.txt b/test/fspp/CMakeLists.txt index 65c9fa63..28693e74 100644 --- a/test/fspp/CMakeLists.txt +++ b/test/fspp/CMakeLists.txt @@ -106,5 +106,5 @@ add_executable(${PROJECT_NAME} ${SOURCES}) target_link_libraries(${PROJECT_NAME} fspp) add_test(${PROJECT_NAME} ${PROJECT_NAME}) -enable_style_warnings(${PROJECT_NAME}) -activate_cpp14(${PROJECT_NAME}) +target_enable_style_warnings(${PROJECT_NAME}) +target_activate_cpp14(${PROJECT_NAME}) diff --git a/utils.cmake b/utils.cmake index da284939..18a0edf2 100644 --- a/utils.cmake +++ b/utils.cmake @@ -3,42 +3,42 @@ include(CheckCXXCompilerFlag) ################################################### # Activate C++14 # -# Uses: ACTIVATE_CPP14(buildtarget) +# Uses: target_activate_cpp14(buildtarget) ################################################### -function(ACTIVATE_CPP14 TARGET) - CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_HAS_CPP14_SUPPORT) +function(target_activate_cpp14 TARGET) + check_cxx_compiler_flag("-std=c++14" COMPILER_HAS_CPP14_SUPPORT) IF (COMPILER_HAS_CPP14_SUPPORT) - TARGET_COMPILE_OPTIONS(${TARGET} PUBLIC -std=c++14) + target_compile_options(${TARGET} PUBLIC -std=c++14) ELSE() - CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_HAS_CPP14_PARTIAL_SUPPORT) + check_cxx_compiler_flag("-std=c++1y" COMPILER_HAS_CPP14_PARTIAL_SUPPORT) IF (COMPILER_HAS_CPP14_PARTIAL_SUPPORT) - TARGET_COMPILE_OPTIONS(${TARGET} PUBLIC -std=c++1y) + target_compile_options(${TARGET} PUBLIC -std=c++1y) ELSE() - MESSAGE(FATAL_ERROR "Compiler doesn't support C++14") + message(FATAL_ERROR "Compiler doesn't support C++14") ENDIF() ENDIF() IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - TARGET_COMPILE_OPTIONS(${TARGET} PUBLIC -stdlib=libc++) + target_compile_options(${TARGET} PUBLIC -stdlib=libc++) ENDIF() -endfunction(ACTIVATE_CPP14) +endfunction(target_activate_cpp14) ################################################# # Enable style compiler warnings # -# Uses: ENABLE_STYLE_WARNINGS(buildtarget) +# Uses: target_enable_style_warnings(buildtarget) ################################################# -function(ENABLE_STYLE_WARNINGS TARGET) - TARGET_COMPILE_OPTIONS(${TARGET} PRIVATE -Wall -Wextra) -endfunction(ENABLE_STYLE_WARNINGS) +function(target_enable_style_warnings TARGET) + target_compile_options(${TARGET} PRIVATE -Wall -Wextra) +endfunction(target_enable_style_warnings) ################################################## # Add boost to the project # # Uses: -# ADD_BOOST(buildtarget) # if you're only using header-only boost libs -# ADD_BOOST(buildtarget system filesystem) # list all libraries to link against in the dependencies +# target_add_boost(buildtarget) # if you're only using header-only boost libs +# target_add_boost(buildtarget system filesystem) # list all libraries to link against in the dependencies ################################################## -function(ADD_BOOST TARGET) +function(target_add_boost TARGET) # Load boost libraries find_package(Boost 1.56.0 REQUIRED @@ -46,19 +46,19 @@ function(ADD_BOOST TARGET) set(Boost_USE_STATIC_LIBS ON) target_include_directories(${TARGET} SYSTEM PRIVATE ${Boost_INCLUDE_DIRS}) target_link_libraries(${TARGET} PRIVATE ${Boost_LIBRARIES}) -endfunction() +endfunction(target_add_boost) ################################################## # Specify that a specific minimal version of gcc is required # # Uses: -# REQUIRE_GCC_VERSION(4.9) +# require_gcc_version(4.9) ################################################## -function(REQUIRE_GCC_VERSION) +function(require_gcc_version) if (CMAKE_COMPILER_IS_GNUCXX) execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) if (GCC_VERSION VERSION_LESS ${ARGN}) message(FATAL_ERROR "Needs at least gcc version ${ARGN}, found gcc ${GCC_VERSION}") endif (GCC_VERSION VERSION_LESS ${ARGN}) endif (CMAKE_COMPILER_IS_GNUCXX) -endfunction() +endfunction(require_gcc_version)