Skip to content

Commit a7e62e8

Browse files
committed
Adding cmake file. Fixes for msvc support. Currently 36 out of 43 demos can build with msvc.
1 parent 7ccbdde commit a7e62e8

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

CMakeLists.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required( VERSION 2.6 )
2+
project( algorithm )
3+
4+
include_directories( "include" )
5+
include_directories( "." )
6+
if( MSVC )
7+
include_directories( "msvc" )
8+
endif()
9+
10+
#add_executable(word_seg "src/word_seg_demo.cpp")
11+
#add_executable(astar "src/astar_demo.cpp")
12+
13+
file( GLOB APP_SOURCES src/*.cpp )
14+
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FI\"msvc/alg_vs.h\"" )
15+
message( ${CMAKE_CXX_FLAGS} )
16+
foreach( appsourcefile ${APP_SOURCES} )
17+
get_filename_component( demo_name ${appsourcefile} NAME_WE )
18+
add_executable( ${demo_name} ${appsourcefile} )
19+
endforeach( appsourcefile ${APP_SOURCES} )

msvc/alg_vs.h

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef __ALGVS_H__
2+
#define __ALGVS_H__
3+
#ifdef _MSC_VER
4+
5+
#define _CRT_SECURE_NO_WARNINGS
6+
7+
#define __func__ __FUNCTION__
8+
9+
#define strtok_r strtok_s
10+
11+
#if _MSC_VER <= 1700
12+
#define ALG_VLA_NOT_SUPPORTED 1
13+
#endif
14+
15+
#define typeof decltype
16+
17+
#endif//_MSC_VER
18+
#endif//__ALGVS_H__

msvc/stdbool.h

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#ifdef _MSC_VER
2+
3+
#endif

0 commit comments

Comments
 (0)