@@ -48,54 +48,76 @@ env.EnsureSConsVersion(0, 98, 1)
4848# Customizable compile variables
4949vars = Variables ('sconsvars.py' )
5050
51- # TODO: also amend paths when VIRTUAL_ENV variable exists,
52- # if CONDA_PREFIX does not exist ?
53- if 'CONDA_PREFIX' in os .environ :
51+ # Set PREFIX for installation and linking
52+ # TODO: also amend paths when VIRTUAL_ENV variable exists ?
53+ if 'PREFIX' in os .environ :
54+ # building with a set prefix
55+ vars .Add (PathVariable (
56+ 'prefix' ,
57+ 'installation prefix directory' ,
58+ os .environ ['PREFIX' ]))
59+ vars .Update (env )
60+ elif 'CONDA_PREFIX' in os .environ :
5461 # building for a conda environment
5562 vars .Add (PathVariable (
5663 'prefix' ,
5764 'installation prefix directory' ,
5865 os .environ ['CONDA_PREFIX' ]))
5966 vars .Update (env )
60- if platform .system ().lower () == "windows" :
61- vars .Add (PathVariable (
62- 'libdir' ,
63- 'installation directory for compiled library [prefix/Library/lib]' ,
64- pjoin (env ['prefix' ], 'Library' , 'Lib' ),
65- PathVariable .PathAccept ))
66- vars .Add (PathVariable (
67- 'includedir' ,
68- 'installation directory for C++ header files [prefix/Library/include]' ,
69- pjoin (env ['prefix' ], 'Library' , 'include' ),
70- PathVariable .PathAccept ))
71- else :
72- vars .Add (PathVariable (
73- 'libdir' ,
74- 'installation directory for compiled library [prefix/lib]' ,
75- pjoin (env ['prefix' ], 'lib' ),
76- PathVariable .PathAccept ))
77- vars .Add (PathVariable (
78- 'includedir' ,
79- 'installation directory for C++ header files [prefix/include]' ,
80- pjoin (env ['prefix' ], 'include' ),
81- PathVariable .PathAccept ))
8267else :
68+ # Default: install in /usr/local
8369 vars .Add (PathVariable (
8470 'prefix' ,
8571 'installation prefix directory' ,
8672 '/usr/local' ))
87- vars .Update (env )
73+
74+ if platform .system ().lower () == "windows" :
75+ # Installation paths
76+ vars .Add (PathVariable (
77+ 'libdir' ,
78+ 'installation directory for compiled library [prefix/Library/lib]' ,
79+ pjoin (env ['prefix' ], 'Library' , 'Lib' ),
80+ PathVariable .PathAccept ))
81+ vars .Add (PathVariable (
82+ 'includedir' ,
83+ 'installation directory for C++ header files [prefix/Library/include]' ,
84+ pjoin (env ['prefix' ], 'Library' , 'include' ),
85+ PathVariable .PathAccept ))
86+
87+ # See https://scons.org/faq.html#Linking_on_Windows_gives_me_an_error
88+ env ['ENV' ]['TMP' ] = os .environ ['TMP' ]
89+ # Prevent the generation of an import lib (.lib) in addition to the dll
90+ # Unused as we are using as static library for windows
91+ # env.AppendUnique(no_import_lib=1)
92+
93+ # Compilation and linking paths
94+ env .Append (CPPPATH = [pjoin (env ['prefix' ], 'include' )])
95+ env .Append (CPPPATH = [pjoin (env ['prefix' ], 'Library' , 'include' )])
96+ env .Append (LIBPATH = pjoin (env ['prefix' ], 'Library' , 'lib' ))
97+ else :
98+ # Installation paths
8899 vars .Add (PathVariable (
89100 'libdir' ,
90101 'installation directory for compiled library [prefix/lib]' ,
91- env ['prefix' ] + '/ lib' ,
102+ pjoin ( env ['prefix' ], ' lib') ,
92103 PathVariable .PathAccept ))
93104 vars .Add (PathVariable (
94105 'includedir' ,
95106 'installation directory for C++ header files [prefix/include]' ,
96- env ['prefix' ] + '/ include' ,
107+ pjoin ( env ['prefix' ], ' include') ,
97108 PathVariable .PathAccept ))
98109
110+ # Compilation and linking paths
111+ env .Append (CPPPATH = [pjoin (env ['prefix' ], 'include' )])
112+ env .Append (LIBPATH = [pjoin (env ['prefix' ], 'lib' )])
113+
114+ # Specify minimum C++ standard. Allow later standard from sconscript.local.
115+ # In case of multiple `-std` options the last option holds.
116+ env .PrependUnique (CXXFLAGS = '-std=c++11' , delete_existing = 1 )
117+
118+ # for k, v in env.Dictionary().items():
119+ # print(k, v)
120+
99121vars .Add (EnumVariable (
100122 'build' ,
101123 'compiler settings' ,
@@ -114,24 +136,6 @@ vars.Add(BoolVariable(
114136vars .Update (env )
115137env .Help (MY_SCONS_HELP % vars .GenerateHelpText (env ))
116138
117- if platform .system ().lower () == "windows" :
118- # See https://scons.org/faq.html#Linking_on_Windows_gives_me_an_error
119- env ['ENV' ]['TMP' ] = os .environ ['TMP' ]
120- # Prevent the generation of an import lib (.lib) in addition to the dll
121- # Unused as we are using as static library for windows
122- # env.AppendUnique(no_import_lib=1)
123- if 'CONDA_PREFIX' in os .environ :
124- env .Append (CPPPATH = [pjoin (os .environ ['CONDA_PREFIX' ], 'include' )])
125- env .Append (CPPPATH = [pjoin (os .environ ['CONDA_PREFIX' ], 'Library' , 'include' )])
126- env .Append (LIBPATH = pjoin (os .environ ['CONDA_PREFIX' ], 'Library' , 'lib' ))
127- else :
128- if 'CONDA_PREFIX' in os .environ :
129- env .Append (CPPPATH = pjoin (os .environ ['CONDA_PREFIX' ], 'include' ))
130- env .Append (LIBPATH = pjoin (os .environ ['CONDA_PREFIX' ], 'lib' ))
131- # Specify minimum C++ standard. Allow later standard from sconscript.local.
132- # In case of multiple `-std` options the last option holds.
133- env .PrependUnique (CXXFLAGS = '-std=c++11' , delete_existing = 1 )
134-
135139# the CPPPATH directories are checked by scons dependency scanner
136140cpppath = getsyspaths ('CPLUS_INCLUDE_PATH' , 'CPATH' )
137141env .AppendUnique (CPPPATH = cpppath )
0 commit comments