CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
PROJECT(LIBSECUREC)

SET(CMAKE_VERBOSE_MAKEFILEON ON)
MESSAGE(STATUS "Building LIBSECUREC Library.")

IF(NOT DEFINED MINGW_DIR)
	set(MINGW_DIR "D:\\msys32\\mingw32")
ENDIF(NOT DEFINED MINGW_DIR)

SET(PWD_DIR ${CMAKE_CURRENT_SOURCE_DIR})
SET(MINGW32_DIR ${MINGW_DIR}/"i686-w64-mingw32")
SET(LIBRARY_OUTPUT_PATH ${PWD_DIR}/output)
SET(CMAKE_C_COMPILER "${MINGW_DIR}/bin/i686-w64-mingw32-gcc")

IF(NOT DEFINED RELEASE)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -std=gnu++11 -D_MINGW32 -fPIC -fPIE -pie -m32 -w")
ELSE(NOT DEFINED RELEASE)
	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -std=gnu++11 -D_MINGW32 -fPIC -fPIE -pie -m32 -w")
ENDIF(NOT DEFINED RELEASE)

INCLUDE_DIRECTORIES(${PWD_DIR}/include)

SET(SRC_LIST ${PWD_DIR}/src/fscanf_s.c 
     ${PWD_DIR}/src/memmove_s.c 
     ${PWD_DIR}/src/snprintf_s.c 
     ${PWD_DIR}/src/strncpy_s.c 
     ${PWD_DIR}/src/vscanf_s.c 
     ${PWD_DIR}/src/vwscanf_s.c 
     ${PWD_DIR}/src/wmemcpy_s.c 
     ${PWD_DIR}/src/fwscanf_s.c 
     ${PWD_DIR}/src/memset_s.c 
     ${PWD_DIR}/src/secureinput_a.c 
     ${PWD_DIR}/src/sprintf_s.c 
     ${PWD_DIR}/src/strtok_s.c 
     ${PWD_DIR}/src/vsnprintf_s.c 
     ${PWD_DIR}/src/wcscat_s.c 
     ${PWD_DIR}/src/wmemmove_s.c 
     ${PWD_DIR}/src/gets_s.c 
     ${PWD_DIR}/src/secureinput_w.c 
     ${PWD_DIR}/src/sscanf_s.c 
     ${PWD_DIR}/src/swprintf_s.c 
     ${PWD_DIR}/src/vsprintf_s.c 
     ${PWD_DIR}/src/wcscpy_s.c 
     ${PWD_DIR}/src/wscanf_s.c 
     ${PWD_DIR}/src/scanf_s.c 
     ${PWD_DIR}/src/strcat_s.c 
     ${PWD_DIR}/src/swscanf_s.c 
     ${PWD_DIR}/src/vsscanf_s.c 
     ${PWD_DIR}/src/wcsncat_s.c 
     ${PWD_DIR}/src/secureprintoutput_a.c
     ${PWD_DIR}/src/strcpy_s.c 
     ${PWD_DIR}/src/vfscanf_s.c 
     ${PWD_DIR}/src/vswprintf_s.c 
     ${PWD_DIR}/src/wcsncpy_s.c 
     ${PWD_DIR}/src/securecutil.c 
     ${PWD_DIR}/src/secureprintoutput_w.c 
     ${PWD_DIR}/src/strncat_s.c 
     ${PWD_DIR}/src/vfwscanf_s.c 
     ${PWD_DIR}/src/vswscanf_s.c 
     ${PWD_DIR}/src/wcstok_s.c)
#     ${PWD_DIR}/src/memcpy_s.o 


ADD_LIBRARY(OBJ_LIBSECUREC OBJECT ${SRC_LIST}) 
SET_PROPERTY(TARGET OBJ_LIBSECUREC PROPERTY POSITION_INDEPENDENT_CODE 1)

ADD_LIBRARY(LIB_LIBSECUREC STATIC $<TARGET_OBJECTS:OBJ_LIBSECUREC>)
SET_TARGET_PROPERTIES(LIB_LIBSECUREC PROPERTIES PREFIX "")
SET_TARGET_PROPERTIES(LIB_LIBSECUREC PROPERTIES OUTPUT_NAME "libsecurec")
SET_TARGET_PROPERTIES(LIB_LIBSECUREC PROPERTIES SUFFIX ".lib")


