source: sasview/sansmodels/generate_cmake.py @ 4bdd4fdb

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 4bdd4fdb was 62dc94b, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

Add quick test for the C++ library

  • Property mode set to 100644
File size: 1.6 KB
Line 
1"""
2    Script to generate a CMakeLists.txt file for cmake
3   
4    python generate_cmake.py
5    cd [your build location not in the source tree]
6    cmake [path to directory containing CMakeLists.txt]
7    make
8   
9    That will produce a library libModels.a
10"""
11import os
12f = open("CMakeLists.txt", "w")
13
14cmakelist = """# CMakeLists for SANS models
15cmake_minimum_required (VERSION 2.6)
16project (SansModels)
17
18# Version number
19set (SansModels_VERSION_MAJOR 1)
20set (SansModels_VERSION_MAJOR 0)
21
22set (SRC_FILES
23"""
24
25source_dirs = ["src/c_models",
26               "src/libigor"]
27excluded_src = ["c_models.cpp",
28                "disperser.c",
29                "winFuncs.c"]
30
31for src_dir in source_dirs:
32    for item in os.listdir(src_dir):
33        if item in excluded_src:
34            continue
35        ext = os.path.splitext(item)[1]
36        if ext in [".c",".cpp"]:
37            cmakelist += "    %s\n" % os.path.join(src_dir, item)
38
39cmakelist += "    )\n\n"   
40
41cmakelist += "set ( INC_FILES\n"   
42
43include_dirs = ["src/c_models",
44                "include",
45                "src/libigor"]
46
47for inc_dir in include_dirs:
48    for item in os.listdir(inc_dir):
49        ext = os.path.splitext(item)[1]
50        if ext in [".h",".hh"]:
51            cmakelist += "    %s\n" % os.path.join(inc_dir, item)
52   
53cmakelist += """
54)
55   
56include_directories (src/libigor include src/c_models)
57
58# Add the target for this directory
59add_library ( models ${SRC_FILES} ${INC_FILES})
60add_executable( libraryTest test/library_test.cpp  ${INC_FILES})
61ADD_DEFINITIONS(-D__MODELS_STANDALONE__)
62ADD_DEPENDENCIES(libraryTest models)
63TARGET_LINK_LIBRARIES(libraryTest models)
64"""
65
66f.write(cmakelist)
67f.close()
68
69   
Note: See TracBrowser for help on using the repository browser.