forked from lorf/csr-spi-ftdi
-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
63 lines (48 loc) · 2.33 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
cmake_minimum_required(VERSION 3.1.0)
project (usbspi)
if (NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
message("current build type is ${CMAKE_BUILD_TYPE}")
# Force to generate only Debug/Release configuration, and make Release to generate PDB.
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} CACHE STRING "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE ${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} CACHE STRING "" FORCE)
set(CMAKE_STATIC_LINKER_FLAGS_RELEASE ${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} CACHE STRING "" FORCE)
if(CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES Debug Release)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Configurations" FORCE)
endif()
# Use static-link crt libraries
#foreach(flag_var
# CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
# CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
# if(${flag_var} MATCHES "/MD")
# string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
# endif(${flag_var} MATCHES "/MD")
#endforeach(flag_var)
# Use C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
message(STATUS "C++11 support has been enabled by default.")
if (WIN32)
# set to unicdoe
ADD_DEFINITIONS(-D_UNICODE)
# Remove 'lib' prefix for shared libraries on Windows
set(CMAKE_SHARED_LIBRARY_PREFIX "")
# Without SAFESEH
SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
SET (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set_property(GLOBAL PROPERTY USE_FOLDERS ON) # We folder to separate targets
# Make sure all projects can access each other.
include_directories("${PROJECT_SOURCE_DIR}")
FILE(GLOB CC_FILES *.c *.cc *.cpp *.h)
add_library(${PROJECT_NAME} SHARED ${CC_FILES} usbspi.dll.def)
set_source_files_properties(usbspi.dll.def PROPERTIES HEADER_FILE_ONLY TRUE)
include("usbiox/usbiox.cmake")
target_link_libraries(${PROJECT_NAME} usbiox)