Browse Source

Fixed CMakeLists.txt, made everything compile under Windows/MSVC

Added popcnt for MSVC
Fixed line ending detection in parser
tempestpy_adaptions
PBerger 12 years ago
parent
commit
851e3a631d
  1. 35
      CMakeLists.txt
  2. 1
      src/mrmc.cpp
  3. 6
      src/parser/parser.cpp
  4. 5
      src/parser/parser.h
  5. 4
      src/parser/readLabFile.cpp
  6. 5
      src/storage/BitVector.h
  7. 13
      src/utility/osDetection.h

35
CMakeLists.txt

@ -9,17 +9,32 @@ set (MRMC_CPP_VERSION_MINOR 0)
# Set all GTest references to the version in the repository and show it as output
set (GTEST_INCLUDE_DIR resources/3rdparty/gtest-1.6.0/include)
set (GTEST_LIBRARY ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/libgtest.a)
set (GTEST_MAIN_LIBRARY ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/libgtest_main.a)
if(MSVC)
set (MRMC_LIB_SUFFIX lib)
set (GTEST_LIBRARY_DEBUG ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/build/Debug/gtest.${MRMC_LIB_SUFFIX})
set (GTEST_MAIN_LIBRARY_DEBUG ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/build/Debug/gtest_main.${MRMC_LIB_SUFFIX})
set (GTEST_LIBRARY ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/build/Release/gtest.${MRMC_LIB_SUFFIX})
set (GTEST_MAIN_LIBRARY ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/build/Release/gtest_main.${MRMC_LIB_SUFFIX})
set (GTEST_LIBRARIES optimized ${GTEST_LIBRARY} debug ${GTEST_LIBRARY_DEBUG})
else()
set (MRMC_LIB_SUFFIX a)
set (GTEST_LIBRARY ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/libgtest.${MRMC_LIB_SUFFIX})
set (GTEST_MAIN_LIBRARY ${PROJECT_SOURCE_DIR}/resources/3rdparty/gtest-1.6.0/libgtest_main.${MRMC_LIB_SUFFIX})
set (GTEST_LIBRARIES ${GTEST_LIBRARY}) # as we dont use FindGTest anymore
endif()
message(STATUS "GTEST_INCLUDE_DIR is ${GTEST_INCLUDE_DIR}")
message(STATUS "GTEST_LIBRARY is ${GTEST_LIBRARY}")
message(STATUS "GTEST_MAIN_LIBRARY is ${GTEST_MAIN_LIBRARY}")
# Set all log4cplus references the version in the repository
set (LOG4CPLUS_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.0/include)
set (LOG4CPLUS_LIBRARY ${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.0/src/liblog4cplus.a)
if (MSVC)
set (LOG4CPLUS_LIBRARIES optimized ${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.0/msvc10/x64/bin.Release/log4cplusS.${MRMC_LIB_SUFFIX} debug ${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.0/msvc10/x64/bin.Debug/log4cplusSD.${MRMC_LIB_SUFFIX})
else()
set (LOG4CPLUS_LIBRARIES ${PROJECT_SOURCE_DIR}/resources/3rdparty/log4cplus-1.1.0/src/liblog4cplus.${MRMC_LIB_SUFFIX})
endif()
message(STATUS "LOG4CPLUS_INCLUDE_DIR is ${LOG4CPLUS_INCLUDE_DIR}")
message(STATUS "LOG4CPLUS_LIBRARY is ${LOG4CPLUS_LIBRARY}")
message(STATUS "LOG4CPLUS_LIBRARY is ${LOG4CPLUS_LIBRARIES}")
# Set all Eigen references the version in the repository
set(EIGEN3_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty/eigen)
@ -52,7 +67,8 @@ if(CMAKE_COMPILER_IS_GNUCC)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
endif(USE_POPCNT)
elseif(MSVC)
# required for GMM to compile, ugly error directive in their code
add_definitions(/D_SCL_SECURE_NO_DEPRECATE)
else(CLANG)
# Set standard flags for GCC
set (CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall -Werror -pedantic -Wno-unused-variable")
@ -88,12 +104,13 @@ source_group(Headers FILES ${MRMC_TEST_HEADERS})
source_group(Sources FILES ${MRMC_TEST_SOURCES})
# Add base folder for better inclusion paths
include_directories("${PROJECT_SOURCE_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/src")
# Set required external packages
find_package(Threads REQUIRED)
find_package(Doxygen REQUIRED)
#set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost REQUIRED COMPONENTS program_options)
@ -141,7 +158,7 @@ if (GTEST_INCLUDE_DIR)
enable_testing()
include_directories(${GTEST_INCLUDE_DIR})
target_link_libraries(mrmc-tests ${GTEST_LIBRARY} ${GTEST_MAIN_LIBRARY})
target_link_libraries(mrmc-tests ${GTEST_LIBRARIES})
add_test(NAME mrmc-tests COMMAND mrmc-tests)
if(MSVC) # VS2012 doesn't support correctly the tuples yet
@ -151,8 +168,8 @@ endif(GTEST_INCLUDE_DIR)
if (LOG4CPLUS_INCLUDE_DIR)
include_directories(${LOG4CPLUS_INCLUDE_DIR})
target_link_libraries(mrmc ${LOG4CPLUS_LIBRARY})
target_link_libraries(mrmc-tests ${LOG4CPLUS_LIBRARY})
target_link_libraries(mrmc ${LOG4CPLUS_LIBRARIES})
target_link_libraries(mrmc-tests ${LOG4CPLUS_LIBRARIES})
# On Linux, we have to link against librt
if (UNIX AND NOT APPLE)
target_link_libraries(mrmc rt)

1
src/mrmc.cpp

@ -12,6 +12,7 @@
* Description: Central part of the application containing the main() Method
*/
#include "src/utility/osDetection.h"
#include <iostream>
#include <cstdio>
#include <sstream>

6
src/parser/parser.cpp

@ -1,15 +1,13 @@
#include "src/parser/parser.h"
#if defined LINUX || defined MACOSX
#include <sys/mman.h>
# include <sys/mman.h>
# include <unistd.h>
#elif defined WINDOWS
#endif
#include <sys/stat.h>
#include <fcntl.h>
//#if defined MACOSX
#include <unistd.h>
//#endif
#include <errno.h>
#include <iostream>
#include <cstring>

5
src/parser/parser.h

@ -11,8 +11,10 @@
#include "src/utility/osDetection.h"
#if defined LINUX || defined MACOSX
#include <sys/mman.h>
# include <sys/mman.h>
#elif defined WINDOWS
# include <Windows.h>
# include <winnt.h>
#endif
#include <sys/stat.h>
@ -20,6 +22,7 @@
#include <errno.h>
#include <iostream>
#include <boost/integer/integer_mask.hpp>
#include "src/exceptions/file_IO_exception.h"
#include "src/exceptions/wrong_file_format.h"

4
src/parser/readLabFile.cpp

@ -57,7 +57,11 @@ LabParser::LabParser(uint_fast64_t node_count, const char * filename)
/*
* first run: obtain number of propositions
*/
#ifdef WINDOWS
char separator[] = " \r\n\t";
#else
char separator[] = " \n\t";
#endif
bool foundDecl = false, foundEnd = false;
uint_fast32_t proposition_count = 0;
{

5
src/storage/BitVector.h

@ -10,6 +10,7 @@
#include "src/exceptions/invalid_argument.h"
#include "src/exceptions/out_of_range.h"
#include "src/utility/osDetection.h"
#include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.h"
@ -394,6 +395,10 @@ public:
// Check if we are using g++ or clang++ and, if so, use the built-in function
#if (defined (__GNUG__) || defined(__clang__))
result += __builtin_popcountll(this->bucketArray[i]);
#elif defined WINDOWS
#include <nmmintrin.h>
// if the target machine does not support SSE4, this will fail.
result += _mm_popcnt_u64(this->bucketArray[i]);
#else
uint_fast32_t cnt;
uint_fast64_t bitset = this->bucketArray[i];

13
src/utility/osDetection.h

@ -1,12 +1,15 @@
#pragma once
#if defined __linux__ || defined __linux
#define LINUX
# define LINUX
#elif defined TARGET_OS_MAC || defined __apple__ || defined __APPLE__
#define MACOSX
#define _DARWIN_USE_64_BIT_INODE
# define MACOSX
# define _DARWIN_USE_64_BIT_INODE
#elif defined _WIN32 || defined _WIN64
#define WINDOWS
# define WINDOWS
# define NOMINMAX
# include <Windows.h>
# include <winnt.h>
#else
#error Could not detect Operating System
# error Could not detect Operating System
#endif
Loading…
Cancel
Save