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 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_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_INCLUDE_DIR is ${GTEST_INCLUDE_DIR}")
message(STATUS "GTEST_LIBRARY is ${GTEST_LIBRARY}") message(STATUS "GTEST_LIBRARY is ${GTEST_LIBRARY}")
message(STATUS "GTEST_MAIN_LIBRARY is ${GTEST_MAIN_LIBRARY}") message(STATUS "GTEST_MAIN_LIBRARY is ${GTEST_MAIN_LIBRARY}")
# Set all log4cplus references the version in the repository # 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_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_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 all Eigen references the version in the repository
set(EIGEN3_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty/eigen) 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") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mpopcnt")
endif(USE_POPCNT) endif(USE_POPCNT)
elseif(MSVC) elseif(MSVC)
# required for GMM to compile, ugly error directive in their code
add_definitions(/D_SCL_SECURE_NO_DEPRECATE)
else(CLANG) else(CLANG)
# Set standard flags for GCC # Set standard flags for GCC
set (CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++ -Wall -Werror -pedantic -Wno-unused-variable") 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}) source_group(Sources FILES ${MRMC_TEST_SOURCES})
# Add base folder for better inclusion paths # Add base folder for better inclusion paths
include_directories("${PROJECT_SOURCE_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/src") include_directories("${PROJECT_SOURCE_DIR}/src")
# Set required external packages # Set required external packages
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
find_package(Doxygen 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_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF) set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost REQUIRED COMPONENTS program_options) find_package(Boost REQUIRED COMPONENTS program_options)
@ -141,7 +158,7 @@ if (GTEST_INCLUDE_DIR)
enable_testing() enable_testing()
include_directories(${GTEST_INCLUDE_DIR}) 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) add_test(NAME mrmc-tests COMMAND mrmc-tests)
if(MSVC) # VS2012 doesn't support correctly the tuples yet if(MSVC) # VS2012 doesn't support correctly the tuples yet
@ -151,8 +168,8 @@ endif(GTEST_INCLUDE_DIR)
if (LOG4CPLUS_INCLUDE_DIR) if (LOG4CPLUS_INCLUDE_DIR)
include_directories(${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 # On Linux, we have to link against librt
if (UNIX AND NOT APPLE) if (UNIX AND NOT APPLE)
target_link_libraries(mrmc rt) target_link_libraries(mrmc rt)

1
src/mrmc.cpp

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

6
src/parser/parser.cpp

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

5
src/parser/parser.h

@ -11,8 +11,10 @@
#include "src/utility/osDetection.h" #include "src/utility/osDetection.h"
#if defined LINUX || defined MACOSX #if defined LINUX || defined MACOSX
#include <sys/mman.h>
# include <sys/mman.h>
#elif defined WINDOWS #elif defined WINDOWS
# include <Windows.h>
# include <winnt.h>
#endif #endif
#include <sys/stat.h> #include <sys/stat.h>
@ -20,6 +22,7 @@
#include <errno.h> #include <errno.h>
#include <iostream> #include <iostream>
#include <boost/integer/integer_mask.hpp>
#include "src/exceptions/file_IO_exception.h" #include "src/exceptions/file_IO_exception.h"
#include "src/exceptions/wrong_file_format.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 * first run: obtain number of propositions
*/ */
#ifdef WINDOWS
char separator[] = " \r\n\t";
#else
char separator[] = " \n\t"; char separator[] = " \n\t";
#endif
bool foundDecl = false, foundEnd = false; bool foundDecl = false, foundEnd = false;
uint_fast32_t proposition_count = 0; uint_fast32_t proposition_count = 0;
{ {

5
src/storage/BitVector.h

@ -10,6 +10,7 @@
#include "src/exceptions/invalid_argument.h" #include "src/exceptions/invalid_argument.h"
#include "src/exceptions/out_of_range.h" #include "src/exceptions/out_of_range.h"
#include "src/utility/osDetection.h"
#include "log4cplus/logger.h" #include "log4cplus/logger.h"
#include "log4cplus/loggingmacros.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 // Check if we are using g++ or clang++ and, if so, use the built-in function
#if (defined (__GNUG__) || defined(__clang__)) #if (defined (__GNUG__) || defined(__clang__))
result += __builtin_popcountll(this->bucketArray[i]); 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 #else
uint_fast32_t cnt; uint_fast32_t cnt;
uint_fast64_t bitset = this->bucketArray[i]; uint_fast64_t bitset = this->bucketArray[i];

13
src/utility/osDetection.h

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