-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
88 lines (64 loc) · 3.48 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
cmake_minimum_required(VERSION 2.8)
project(bmlangmap)
set( CMAKE_VERBOSE_MAKEFILE on )
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/build/bin)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR})
include_directories("${PROJECT_SOURCE_DIR}/bm" "${PROJECT_SOURCE_DIR}/libbm/include")
MESSAGE( STATUS "CMAKE_CXX_COMPILER_ID: " ${CMAKE_CXX_COMPILER_ID} )
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
if ("${BMOPTFLAGS}" STREQUAL "BMSSE42OPT")
set(bmoptf "-march=nehalem -msse4.2 -DBMSSE42OPT")
elseif("${BMOPTFLAGS}" STREQUAL "BMAVX2OPT")
set(bmoptf "-march=skylake -mavx2 -DBMAVX2OPT")
else()
#set(bmoptf "-march=core2")
endif()
set(LINKER_FLAGS "-nodefaultlibs -lc")
set(LD_FLAGS ${LINKER_FLAGS})
set(LDFLAGS ${LINKER_FLAGS})
set(CMAKE_SHARED_LINKER_FLAGS ${LINKER_FLAGS})
set(flags "-Wall -Wextra -fPIC -fno-rtti -fno-exceptions ")
set(optflags "-g0 -O2")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(flags, "-tpp7 -march=core2 -restrict -DBM_HASRESTRICT -fno-fnalias -Wall -fPIC")
set(optflags, "-g0 -O3 -opt_report_fileopt.txt -opt_report_levelmax")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
if ("${BMOPTFLAGS}" STREQUAL "BMSSE42OPT")
set(bmoptf "-DBMSSE42OPT")
elseif("${BMOPTFLAGS}" STREQUAL "BMAVX2OPT")
set(bmoptf "-DBMAVX2OPT")
endif()
set(flags "/W4 /EHsc /F 5000000 ")
set(optflags "-O2")
SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:\"10000000\"")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flags} ${bmoptf}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flags} ${optflags} ${bmoptf}")
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${ldflags}")
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${ldflags}")
add_library(bm-static STATIC "libbm/src/libbm.cpp")
add_library(bm-dll SHARED "libbm/src/libbm.cpp")
add_library(bmcpuid SHARED "libbm/src/libbmcpuid.c")
add_library(bm-dll-sse42 SHARED "libbm/src/libbm.cpp")
add_library(bm-dll-avx2 SHARED "libbm/src/libbm.cpp")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set_target_properties(bmcpuid PROPERTIES COMPILE_FLAGS "-DBMDLLEXPORTS")
set_target_properties(bm-dll PROPERTIES COMPILE_FLAGS "-DBMDLLEXPORTS")
set_target_properties(bm-dll-sse42 PROPERTIES COMPILE_FLAGS "-DBMDLLEXPORTS -DBMSSE42OPT")
set_target_properties(bm-dll-avx2 PROPERTIES COMPILE_FLAGS "-DBMDLLEXPORTS -DBMAVX2OPT")
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set_target_properties(bm-dll PROPERTIES COMPILE_FLAGS "-march=core2")
set_target_properties(bm-dll-sse42 PROPERTIES COMPILE_FLAGS "-march=nehalem -msse4.2 -DBMSSE42OPT")
set_target_properties(bm-dll-avx2 PROPERTIES COMPILE_FLAGS "-march=skylake -mavx2 -DBMAVX2OPT")
endif()
add_executable(libbmtest ${PROJECT_SOURCE_DIR}/test/libbmtest.c)
#set_property(TARGET target PROPERTY CMAKE_SHARED_LINKER_FLAGS “${CMAKE_SHARED_LINKER} -nodefaultlibs -lc”)
#set_property(TARGET libbmtest PROPERTY CMAKE_SHARED_LINKER_FLAGS “${CMAKE_SHARED_LINKER} -nodefaultlibs -lc”)
#set_property(TARGET libbmtest PROPERTY CMAKE_EXE_LINKER_FLAGS “${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}”)
target_link_libraries(libbmtest bm-static ${LINKER_FLAGS})
MESSAGE( STATUS "LINKER_FLAGS: " ${LINKER_FLAGS} )
MESSAGE( STATUS "CMAKE_EXE_LINKER_FLAGS: " ${CMAKE_EXE_LINKER_FLAGS} )