diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b93ed1..54e89a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,20 +1,27 @@ -cmake_minimum_required(VERSION 3.3.0) -project (linecount) +CMAKE_MINIMUM_REQUIRED(VERSION 3.3.0) +PROJECT (LINECOUNT) -set(CMAKE_CXX_FLAGS_RELEASE "-O3") -set(CMAKE_C_FLAGS_RELEASE "-O3") +IF(MSVC) + 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_static STATIC linecount.cpp linecount.h) -add_executable (lc main.cpp) -target_link_libraries (lc linecount_static) +ADD_LIBRARY (linecount SHARED linecount.cpp linecount.h) +ADD_LIBRARY (linecount_static STATIC linecount.cpp linecount.h) +ADD_EXECUTABLE (lc main.cpp) +TARGET_LINK_LIBRARIES (lc linecount_static) -install(TARGETS lc +INSTALL(TARGETS lc DESTINATION "bin" ) -install(TARGETS linecount linecount_static +INSTALL(TARGETS linecount linecount_static DESTINATION "lib" ) -install(FILES linecount.h +INSTALL(FILES linecount.h DESTINATION "include" ) diff --git a/linecount.cpp b/linecount.cpp index d2de1c7..2654931 100644 --- a/linecount.cpp +++ b/linecount.cpp @@ -1,4 +1,8 @@ #include"linecount.h" +#include +#ifdef min +#undef min +#endif ///////////////////////////// Platform specific #ifdef _WIN32 @@ -8,7 +12,7 @@ #define LCCLOSEFILE(handle) CloseHandle(handle) #define LCINVALIDHANDLE INVALID_HANDLE_VALUE #define LCSETREALLASTERROR(err, errstr) { setLastError((err), (errstr)); } -#define MAP_FAILED NULL; +#define MAP_FAILED NULL typedef long long LCFILEOFFSET; #elif defined (__unix__) || (defined (__APPLE__) && defined (__MACH__))