build updates

This commit is contained in:
Christien Rioux 2015-12-12 10:42:44 -08:00
parent d1a4df9528
commit 6749faea62
2 changed files with 23 additions and 12 deletions

View File

@ -1,20 +1,27 @@
cmake_minimum_required(VERSION 3.3.0) CMAKE_MINIMUM_REQUIRED(VERSION 3.3.0)
project (linecount) PROJECT (LINECOUNT)
set(CMAKE_CXX_FLAGS_RELEASE "-O3") IF(MSVC)
set(CMAKE_C_FLAGS_RELEASE "-O3") SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "limited configs" FORCE)
SET(CMAKE_CXX_FLAGS_RELEASE "/Ox /Ob2")
SET(CMAKE_C_FLAGS_RELEASE "/Ox /Ob2")
ELSE()
SET(CMAKE_CXX_FLAGS_RELEASE "/O3")
SET(CMAKE_C_FLAGS_RELEASE "-O3")
SET(CMAKE_EXE_LINKER_FLAGS "-s")
ENDIF()
add_library (linecount SHARED linecount.cpp linecount.h) ADD_LIBRARY (linecount SHARED linecount.cpp linecount.h)
add_library (linecount_static STATIC linecount.cpp linecount.h) ADD_LIBRARY (linecount_static STATIC linecount.cpp linecount.h)
add_executable (lc main.cpp) ADD_EXECUTABLE (lc main.cpp)
target_link_libraries (lc linecount_static) TARGET_LINK_LIBRARIES (lc linecount_static)
install(TARGETS lc INSTALL(TARGETS lc
DESTINATION "bin" DESTINATION "bin"
) )
install(TARGETS linecount linecount_static INSTALL(TARGETS linecount linecount_static
DESTINATION "lib" DESTINATION "lib"
) )
install(FILES linecount.h INSTALL(FILES linecount.h
DESTINATION "include" DESTINATION "include"
) )

View File

@ -1,4 +1,8 @@
#include"linecount.h" #include"linecount.h"
#include<algorithm>
#ifdef min
#undef min
#endif
///////////////////////////// Platform specific ///////////////////////////// Platform specific
#ifdef _WIN32 #ifdef _WIN32
@ -8,7 +12,7 @@
#define LCCLOSEFILE(handle) CloseHandle(handle) #define LCCLOSEFILE(handle) CloseHandle(handle)
#define LCINVALIDHANDLE INVALID_HANDLE_VALUE #define LCINVALIDHANDLE INVALID_HANDLE_VALUE
#define LCSETREALLASTERROR(err, errstr) { setLastError((err), (errstr)); } #define LCSETREALLASTERROR(err, errstr) { setLastError((err), (errstr)); }
#define MAP_FAILED NULL; #define MAP_FAILED NULL
typedef long long LCFILEOFFSET; typedef long long LCFILEOFFSET;
#elif defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) #elif defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))