summaryrefslogtreecommitdiff
path: root/hw2/CMakeLists.txt
diff options
context:
space:
mode:
author53hornet <53hornet@gmail.com>2019-02-02 23:33:15 -0500
committer53hornet <53hornet@gmail.com>2019-02-02 23:33:15 -0500
commitdb072ad4dc181eca5a1458656b130beb43f475bf (patch)
treea3c03c7f5497cb70503e2486662fa85cfb53415a /hw2/CMakeLists.txt
downloadcsci427-db072ad4dc181eca5a1458656b130beb43f475bf.tar.xz
csci427-db072ad4dc181eca5a1458656b130beb43f475bf.zip
Diffstat (limited to 'hw2/CMakeLists.txt')
-rw-r--r--hw2/CMakeLists.txt71
1 files changed, 71 insertions, 0 deletions
diff --git a/hw2/CMakeLists.txt b/hw2/CMakeLists.txt
new file mode 100644
index 0000000..984cdf2
--- /dev/null
+++ b/hw2/CMakeLists.txt
@@ -0,0 +1,71 @@
+##################
+# Initialization #
+##################
+# Project name is not mandatory, but you should use it
+project(CSCI427)
+
+# States that CMake required version must be >= 2.6
+cmake_minimum_required(VERSION 2.6)
+
+#####################
+# Setup Environment #
+#####################
+# set to include custom modules
+set(CMAKE_MODULE_PATH $ENV{CMAKE_MODULE_PATH} ${CSCI427_SOURCE_DIR}/cmake)
+
+# set build type if specified by environment
+if((NOT CMAKE_BUILD_TYPE) AND (NOT $ENV{CMAKE_BUILD_TYPE} STREQUAL ""))
+ set(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE})
+endif()
+
+# Set include directories
+include_directories(${CSCI427_SOURCE_DIR}/include)
+
+# Get CPP files
+file(GLOB SRC ${CSCI427_SOURCE_DIR}/src/*cpp)
+
+# Get executable files
+file(GLOB EXECLIST ${CSCI427_SOURCE_DIR}/bin/*cpp)
+
+
+###############
+# C++ Options #
+###############
+# Enable C++11
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+
+# determine build type based on directory name. Do not allow for in source building
+#
+if(${CSCI427_SOURCE_DIR} STREQUAL ${CSCI427_BINARY_DIR})
+ message(FATAL_ERROR " *** In-source building not allowed. Please create a subdir 'Release' or 'Debug', and run cmake from within this directory 'cmake ..' ***")
+else()
+ get_filename_component(TYPE ${CSCI427_BINARY_DIR} NAME)
+ string(TOUPPER "${TYPE}" TYPE)
+ if(${TYPE} STREQUAL "RELEASE")
+ set(CMAKE_BUILD_TYPE Release)
+ else()
+ set(CMAKE_BUILD_TYPE Debug)
+ endif()
+ message("-- Build type set to: ${TYPE}")
+endif()
+
+#######################
+# Set Compile Targets #
+#######################
+# src libraries
+if(NOT SRC STREQUAL "")
+ set(LIBNAME "427_core")
+ add_library(${LIBNAME} ${SRC})
+endif()
+
+# executables
+foreach(EXEC ${EXECLIST})
+ get_filename_component(EXECNAME ${EXEC} NAME_WE)
+ add_executable(${EXECNAME} ${EXEC})
+
+ if(NOT SRC STREQUAL "")
+ target_link_libraries(${EXECNAME} LINK_PUBLIC ${LIBNAME})
+ endif()
+
+ message("-- Adding executable: ${EXECNAME}")
+endforeach(EXEC)