From 33706e7fe56189ede4699ecd87de77a2eb2746a2 Mon Sep 17 00:00:00 2001 From: Joker2770 <1214220480@qq.com> Date: Thu, 19 Nov 2020 10:14:00 +0800 Subject: [PATCH] initial cmake script. --- .gitignore | 1 - CMakeLists.txt | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore index e89b189..2de53f9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ ## files generated by popular Visual Studio add-ons. # User-specific files -*.txt *.o *.so *morse-encode-and-decode diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..23ab545 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.10) + +project(morse-encode-and-decode) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_C_FLAGS, "-Wall") + +if(CMAKE_CONFIGURATION_TYPES) + set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "My multi config types" FORCE) +elseif(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE RELEASE) +endif() + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) +file(GLOB SRCS "src/*.c" "src/*.h") +add_executable(${PROJECT_NAME} ${SRCS}) + +if(UNIX) + set(CMAKE_INSTALL_PREFIX /usr/local) + install(TARGETS ${PROJECT_NAME} DESTINATION bin) +elseif(WIN32) + set(CMAKE_INSTALL_PREFIX "C:/Program Files (x86)/") + install(TARGETS ${PROJECT_NAME} DESTINATION bin) +endif()